javascript - jquery this.id not working -
hello people here code ...
$ (".input_check").change (function (){ if ($ (this).is (':checked')) { console.log(this.id + 'is checked') } else { console.log(this.id + 'is not checked') } }); the above code works fine several check boxes ....but want perform check after page load not after $ (".input_check").change.... tried ...
$ (function () { if ($ (".input_check").is (':checked')) { console.log(this.id + 'is checked') } )} iam trying find id this.id not wrking.. tried (this).id , this.attr("id") still not working... :( getting undefined anyways prepare this??
update :: have multiple checkboxes checked... trying find multiple ids of check boxes checked
(this).id , this.attr("id") not proper jquery syntax situation. should be
$(this).attr('id') fiddle
edit based on comments
ok, stops doing same on document ready?
$(function() { $( ".input_check" ).each(function( index ) { if ($ (this).is (':checked')) { console.log($(this).attr('id') + 'is checked') } else { console.log($(this).attr('id') + 'is not checked') } }); }); fiddle
javascript jquery jquery-ui
No comments:
Post a Comment