JQuery click event works only once

You need to change this line:

$('.option').click(function() {  //etc

to

$('.option').live('click', function(){  //etc

This will ensure that all ‘option’ boxes will get the onclick event. Note that the live method has been replaced in later versions of jQuery with ‘on’. See http://api.jquery.com/on/

EDIT: to use with ‘on’ use delegated events – something like this:

$('#canvas').on('click', '.option', function() { 
    //event handler...
}

Leave a Comment