<div class="a" style="display:none">Content 1</div>
<div class="a" style="display:none">Content 2</div>
some other HTML...
<span id="b">foobar</span>
How can I match the first div class="a" above the span id="b" to show() it? The id="b" is the only thing I know before.
Like this:
$('#b').prevAll('.a:first').show();
$("#b").closest(".a").show();
Try that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With