javascript - Why isn't my checkbox event listener listening correctly? -
yes, i've read related posts on stack overflow. still can't figure out why isn't working.
html:
<input type="checkbox" id="#finished-checker" value="value"> <label for="finished-check">check if assessment complete.</label> javascript:
$('#finished-checker').change(function(){ console.log("this.checked = " + this.checked);//test $.post({ method: 'post', url: '/answers/updatefinishedvalue', data: { finished: this.checked }, success: function (retobj) { console.log(retobj);//test }, error: function () { console.log("error ..."); } }); }); that change function isn't being invoked. i've tried
$('#finished-checker').bind('change',function(){ // ... }); and i've tried putting these in $(document).readys , yada yada.
fiddle of proof: https://jsfiddle.net/c83cd6ah/
remove # id of checkbox finished-checkeruse , use ajax instead of post.
$.ajax({ method: 'post', url: '/answers/updatefinishedvalue', data: { finished: this.checked }, success: function (retobj) { console.log(retobj);//test }, error: function () { console.log("error ..."); } });
Comments
Post a Comment