For a simple single line line, you can use the following chain:
$("#foo").parent().nextAll().children("select");
In the above code, first select the parent element, which is the li element, then select all the siblings that appear after it, and finally return the select elements inside. As seen in this fiddle .
However, this method is cumbersome and slow, as you go along the DOM. Another method that I prefer to use, because it works faster when working with a large set of elements,
Pre-select all select elements, and then create an object with links to the identifier to the index by cyclizing them. Now you can simply connect the jQuery object to get the elements that appear after (or earlier).
// Preselect select elements var selects = $("ul > li > select"), // Prepare empty object to hold index reference idx = {}; // Loop through the select elements and build index reference selects.each(function(i){idx[this.id] = i;}); // Get select elements after
Check the above method for this script .
source share