JavaScript input element syntax error -
hey guys facing strange issue working code looks fine me still getting syntax error
$('input#checkmecustomer').add($('input#checkmencustomer')).live('click',function(e) { /* retrive current id event object */ var target = e.target || e.srcelement; if($('input#'+target.id).is(':checked')) { $('input.'+target.id).each(function() { this.checked = true; }); }else{ $('input.'+target.id).each(function() { this.checked = false; }); } }) });
i uncaught error: syntax error, unrecognized expression: input# in consloe
edit
hey guys , specially benjamin figured out
$(document.body).on('click','#checkmecustomer,#checkmencustomer',function(e) { if($('#'+e.target.id).is(':checked')) { $('.'+e.target.id).each(function() { this.checked = true; }); }else{ $('.'+e.target.id).each(function() { this.checked = false; }); } }) });
looks live depreceated when using it triggering on cliick of every input , button element in dom strange worked out using on
one thing still unclear jquery save refrence of current object in e.target when referring attr e.target.attr('class') getting object has no attr class having that
althought have loved if worked e.target.attr('class')
Comments
Post a Comment