The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Why is 'this' not the jQuery selector? Reply To: Why is 'this' not the jQuery selector?


Thanks for the replies, guys.

Alen, the odd thing is that the range property takes on the height of document even if you pass $(this).height() to it. So instead of this referring to the element that was selected with the method, it skips that level and automatically refers to whatever function the plugin was wrapped in.

If you use this.height() inside the plugin itself, you get the height of the selected element like one would expect…

Ilan, that does indeed work – I added something similar to the first snippet to the examples on the documentation page I’m writing about it. But it seems strange and unnatural that you can’t just use $(this) in the ‘usual’ way. Not seeing the inner logic of that (yet anyway)…