- This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
Viewing 4 posts - 1 through 4 (of 4 total)
- The forum ‘JavaScript’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Home › Forums › JavaScript › JQuery and ‘this’ keyword
OK, so I know that the ‘this’ keyword belongs to the owner of the function it’s in so…
In this example:
‘this’ refers to the current element selected by
Right? or am I crazy?
Also should
actually be
$(this) becomes a jQuery set, and thus is able to have jQuery functions performed on it. At least that’s how I understand it. With "this" by itself, that’s a reference to the element, and you have direct access to DOM stuff like this.offsetLeft or whatnot, but you don’t get all the fun jQuery abilities (like chaining, e.g. $(this).addClass("yeah").slideDown(); ) I’m not even sure if this.addClass(); will work… did you try it?
Yea, I’ve tried both ‘this.addClass()’ and ‘$(this).addClass()’ and neither give the desired result… :(
WOW… I’m sorry I realized when I was looking at stuff, the code above doesn’t even attempt to do what I want it to, and if I wanted to do what it did I would just do
Thanks anyway Chris