jQuery Next-In-DOM
is a jQuery plugin for getting the next or previous element in the full document matching a
specified selector from an element. It basically traverses the whole DOM from the pivot element
to find a matching element and returns the same if found. It is like looking vertically up/down from
an element on a printed out version of the DOM till you find a match.
Tested on Firefox, Google Chrome and IE7 (and up). If you have any suggestions, comments or if you have found a bug, please send it to
vjeleven@gmail.com
Try out the demo below to see it in action. The source for the demo is on the right.
Find the previous matching h2 from this button
Find the next matching a from this button
Reset Highlight
// Find the previous matching h3 from this button
var prevH3 = $(this).prevInDOM('h2');
// Find the next matching a from this button
var nextA = $(this).nextInDOM('a');
Thanks to
John Resig for creating
jQuery. IMHO, it is as world-changing as a JS library can ever expect to become.
Thanks to
google-code-prettify for the super-simple-to-use-and-customize syntax highlighter and for the Vim Sunburst theme.
I am Vijayakrishnan Krishnan. My main area of interest is JavaScript, jQuery, CSS and the awesome things we can achieve with them in combo. I currently work at
DeviceDriven with an amazing team of
engineers covering JS, CSS on the user side to Groovy on Grails, Spring and Hibernate on the server side.