Jump to content

Button quantity doesn't work


Vap-Access

Recommended Posts

Hello !

 

I have a problem with my quantity button, when I click it nothing happens.

I have tested my code here and it works well: https://jsfiddle.net/0zs2p3h5/1/

But once implanted in the site it does not work, nothing happens.

I have another code, which was there before (but which did not work either), available here: http://jsbin.com/juwumobefe/edit?html,output

 

By here if you want to see the live button on my site: here

 

I'm a beginner in Javascript so I think I've forgotten something somewhere but it's been several days that I'm stuck on it so I come to get help!

 

Sorry for my English, this is not my native language

Edited by Vap-Access (see edit history)
Link to comment
Share on other sites

From what I see there are no events attached to up/down arrows

Here is from your jsfiddle: iaecqUqXTzKwWQT-y7ZZRg.png

 

Here is from your website IHrIyKt-TK_36whr_3dc-A.png

 

As you can see there are no events attached to those elements.

 

And based on your page content is logic to happens like this. You've added the js code in your header (<head></head>) which is rendered first, then the <body> content where your elements are. With other others you want to apply js code to elements that are not yet created.

 

What you need to do is bundle your code in a $( document ).ready which is called like this

The .ready() method offers a way to run JavaScript code as soon as the page's Document Object Model (DOM) becomes safe to manipulate.
$( document ).ready(function() {
  // put your code here
});

https://api.jquery.com/ready/

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...