Jump to content

not working after score=3


kadi

Recommended Posts

i just used jquery replaceWith but its seems not working after score=3. the fiddle shows what is going on. please click in this order like button1, button3, button2 then the score increase by point 1 for each button but after score=3 i.e., after clicking all three buttons the score stops and does not respond. i even tried with other button ids but its not working.below is the replace id that i assigned and as the text of the button changes but not responding to score and click.
$("#three").click(function () {$("#three").replaceWith("<button id="three" type="button" data-index="0" >cat</button>"); });
Link to comment
Share on other sites

The button is being replaced, so I don't believe event handlers are carried on. I think jQuery has a function called on() which will keep event handlers assigned to an element after manipulating the DOM.

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...