that would still fail - unless he has a tag named "this" just like doing $("a") finds anchor tags. If however he is using "this" in terms of an event handler (where "this" is a reference to the DOM object that threw the event, then he would need to remove the quotes:

$(this).siblings('h1').height();

In this case "$(this)" says to put the jquery wrapper object around the DOM element represented by "this" in the current context.

The difference is very minor, I know, but I did not see in his description just what "this" represented...

Shawn

Charlie wrote:
you can't use "this" in same manner as tagnames, ID's or class as a selector in combination with other selectors the way you are attempting.

try:

h1Height =  $('this').siblings('h1').height();




Warfang wrote:
I'm pretty new to Javascript/ jQuery, so this is really bugging me.

I'm trying to get the height of an h1 that is a sibling to this. The
value for the variable h1Height, however, returned as null in the
console in Firebug. Perplexed, I tried console.logging ('this'+'+h1')
to see what it was interpreted as. It brought back this+h1, which
should select an h1 adjacent to this (which is a div).

Javascript
h1Height =  $('this'+'h1').height();

What went wrong?


Reply via email to