JQuery.Click function not working properly

I am working on a K-Mapping application for electrical engineering. However, I am stuck in one click function.

if(jQuery) $(document).ready(function(){ $('a').click(function(){ alert("Evaluate Click Works"); var match = $(mintermIndexes).compare(ArrayOfEight); if(match){ alert("All squares have been checked"); } return false; }); }); 

This is HTML,

  <div id="body"> <input id="Clear" value="Clear Form" type="submit" /> <a id="Evaluate" href="#" >Evaluate</a> </div> 

I could really use some help, I really used the only code that I think is the problem. Share your thoughts on how to fix this problem. Thanks.

ps: I tried almost all possible selectors, but still nothing. When I click the link, there is no answer.

EDIT: The order of the links in the header tag has changed, that is, I have changed the order of my jquery application and the jquery reference order. Thanks for the help anyway.

+4
source share
5 answers

I always run into this problem. My solution is to put the script under the tag that I want to control. eg:

 <html> <head> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script> </head> <body> <input id="Clear" value="Clear Form" type="submit" /> <a id="Evaluate" href="#" >Evaluate</a> <script type="text/javascript"> $('a').click(function(){ alert("Evaluate Click Works"); var match = $(mintermIndexes).compare(ArrayOfEight); if(match){ alert("All squares have been checked"); } }); </script> </body> </html> 

explanation:

you need to make sure that the "tag" is loaded first

+1
source

Works great:

http://jsfiddle.net/wCRLE/

Try removing if (jQuery)

Also, did you specify jQuery scripts correctly?

 <script src="http://code.jquery.com/jquery.min.js" type="text/javascript"></script> 
+4
source

Try the following:

 <html> <head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function(){ $('a').click(function(){ alert("Evaluate Click Works"); var match = $(mintermIndexes).compare(ArrayOfEight); if(match){ alert("All squares have been checked"); } return false; }); }); </script> </head> <body> <div id="body"> <input id="Clear" value="Clear Form" type="submit" /> <a id="Evaluate" href="#" >Evaluate</a> </div> </body> </html> 
+1
source

There are no problems here:

http://jsfiddle.net/5Yttd/

0
source

Try to get rid of if (jQuery)

Also, make sure you download jQuery before loading your content scripts. If you do not, nothing will happen.

0
source

Source: https://habr.com/ru/post/1439252/


All Articles