Hello,
I've got some code like this:
<p>Lorem ipsum<a href=# class="a">link</a><span class="b">Text</span>More lorem ipsum<a href=# class="a">link</a><span class="b">Text 2</span>
And I'd like to let users click the link
and be able to do something with the span (make it flash, hide it, whatever). I'm using jQuery, and this is what I've got so far:
$('.a').click(function() {
$(this).nextUntil('.a').css('background-color', 'red');
});
This works as long as I'm diligent about having links before the spans, and no other code in the text. However, I'm not happy with it, and there must be a better way. I've also tried:
$('.a').click(function() {
$(this).next('.b').css('background-color', 'red');
});
But that selects all of the spans of class b
, so no good.
I'm new and at a loss. I seek wisdom.