How to use regular expression in prev()?
<div class="aaa">aaa</div>
<div style="display: none" class="bbb">bbb</div>
<div style="display: none" class="ccc">ccc</div>
<div class="ddd">ddd</div>
$(".ddd").click(function(){
alert($(this).prev('display:visible').attr('class'));
})
This not working. If i have:
This should show me “aaa”. If i remove “display: visible” from prev() then this show me “ccc”.
You can use:
DEMO
prevAll Get all preceding siblings of each element in the set of matched elements, optionally filtered by a selector.
eq(0) to get only the first element.