I have a <ul>
like
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
<li style="display:none;">4</li>
<li class="curSelected">5</li>
<li>6</li>
</ul>
Now from <li>
5 I want the reference of the previous visible element i.e <li>
3
How can I get it?
I tried $('li.curSelected').prev(":visible:last");
But this is not working.
Please help.
Try this:
$('li.curSelected').prevAll(":visible:first");
prev()
returns only the immediate element preceding the selected one. prevAll()
returns all previous.
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