Forum Moderators: open

Message Too Old, No Replies

Selecting this p span with jquery

         

caffinated

11:43 pm on Oct 30, 2010 (gmt 0)

10+ Year Member



So I've got some html like:

<p class="para">blah blah<span class="spanA">some text</span><span class="spanB">more text</span></p>
<p class="para">blah blah<span class="spanA">some text</span><span class="spanB">more text</span></p>
<p class="para">blah blah<span class="spanA">some text</span><span class="spanB">more text</span></p>



and I want to do something to the css of .spanB when this p is hovered

So something like:
s('.para').hover(
function(){
$(this spanB).css(change something)},
function(){
$(this spanB).css(change it back)}
);


But I'm getting the selector bit wrong. I've looked all over the jQuery documentation and in Google but i can't see how to select the spanB belonging to "this".

Any comments appreciated.

caffinated

11:52 pm on Oct 30, 2010 (gmt 0)

10+ Year Member



Darn it. No sooner posted the question than I found the solution:

$(this).find('spanB').css etc...

No need for answers thanks.