javascript - Button onclick to click() jquery -


I currently have a button to respond to onclick (), but I want to work with jquery.

  $ ('# nupp1'). Click (function () {raiseButtonAction (realplayer, gameState);});   

raisebuttonaction is in another .js This piece of code is not working, is anything wrong with me? Edit1:

  $ (document) .ready (function () {$ ('# nupp1') click (function () {raiseButtonAction (realplayer, gamestate);}}}}; <  & Lt; top & gt; & lt; script /> & lt; / head & gt; body & gt; & lt; a id = "nupp1" & gt; & lt; / a & gt;   

The code will not work. The JQuery element will not be able to detect that element must be present in the function.

  & lt; an id = "nupp1" & gt; & lt; / a & gt; & lt; script / & gt;   

will work Since a is being provided before the script.

When you load the DOM node, you can also use it to execute your function.

or you can use.

jQuery API

  • Specify a function to execute the DOM
  • < Li>

Comments