javascript - jQuery this inside event -
javascript - jQuery this inside event -
i tought understand utilize of this in jquery/js, showes me i'm wrong. wanted add together class on dom element , used this:
$("#content").on("click",function(){ this.addclass("bonus"); }); but nil happened, changed sec line of code , worked:
$("#content").addclass("bonus"); shouldn't this in first illustration refer $("#content") already?
this refers dom element triggered. it's not jquery object, native dom object.
you need do:
$(this).addclass("bonus"); javascript jquery dom
Comments
Post a Comment