Jquery won't count checkbox when checked first time -


i have problem jquery script, has count checked boxes, won't count on first time clicked, have check-uncheck-check again in order count. counts correctly in firefox`

   $("#collapseone input[type=checkbox]").click(function( event ) {       var max = 3;       var checkboxes = $('#collapseone     input[type="checkbox"]');    checkboxes.change(function(){       var current = checkboxes.filter(':checked').length;  $( "#col1" ).text(current);       checkboxes.filter(':not(:checked)').prop('disabled', current >= max); }); 

http://jsfiddle.net/nm8t9/

there no need have click handler

var max = 3; var checkboxes = $("#collapseone input[type=checkbox]"); checkboxes.change(function(){     var current = checkboxes.filter(':checked').length;     $( "#col1" ).text(current) ;     checkboxes.filter(':not(:checked)').prop('disabled', current >= max); }); 

demo: fiddle

look @ this demo

your click handler result in registering no-of-clicks - 1 change handler executions


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -