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

Popular posts from this blog

maven fortify plugin : Unable to load build session with ID XXXXX .. See log file for more details -

c# - Primavera WebServices does not return any data -

android - Display emoji panel with genymotion - keyboard/touch input? -