Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the alternate ways to find next().next() in jquery

Tags:

jquery

I want to change the css attribute of element which is just next to next of selector.

I have used this syntax

$('#hide').next().next().css('display', 'block');

but i think there can be another better approach can be use like find() or eq()

<li class="expandable">
    <div class="hitarea collapsable-hitarea"></div>
    <div id="hide" class="hide"></div>
    <a href="#" class=""> <strong>Stitched</strong> </a>

    <ul style="display: none;" id="hi">
        <li> <a href="#"> Hand Block Print </a> 
        </li>
        <li> <a href="#"> Designer </a> 
        </li>
        <li class="last"> <a href="#"> Screen Printed </a> 
        </li>
    </ul>
</li>
like image 977
rahularyansharma Avatar asked Apr 08 '13 08:04

rahularyansharma


1 Answers

You can try

  $('#hide').nextAll().eq(1).css('display', 'block');

nextAll() returns all the next elements, eq(1) returns the second one amongst them.

like image 182
Manishearth Avatar answered Oct 24 '22 02:10

Manishearth