¡@

Home 

2014/10/16 ¤W¤È 12:05:46

jquery Programming Glossary: nextindom

get the next element with a specific class after a specific element

http://stackoverflow.com/questions/11560028/get-the-next-element-with-a-specific-class-after-a-specific-element

Couldn't find a direct way of doing this so wrote a little recursive algorithm for this. Demo http jsfiddle.net sHGDP nextInDOM function takes 2 arguments namely the element to start looking from and the selector to match. instead of '#from date1'.. the element to start looking from and the selector to match. instead of '#from date1' .next '.to date' you can use nextInDOM '.to date' '#from date1' Code function nextInDOM _selector _subject var next getNext _subject while next.length 0 var found.. to match. instead of '#from date1' .next '.to date' you can use nextInDOM '.to date' '#from date1' Code function nextInDOM _selector _subject var next getNext _subject while next.length 0 var found searchFor _selector next if found null return..

Jquery: Forget the DOM structure, just find the next element with this class

http://stackoverflow.com/questions/12873027/jquery-forget-the-dom-structure-just-find-the-next-element-with-this-class

to satisfy all any DOM structure. I once worked out a simple recursive function that does this. It goes like function nextInDOM _selector _subject var next getNext _subject while next.length 0 var found searchFor _selector next if found null return.. this if found null return false return found return null will should never get here And you can call it like nextInDOM 'selector to match' element to start searching from but not inclusive For ex var nextInst nextInDOM '.foo' '#item' will.. can call it like nextInDOM 'selector to match' element to start searching from but not inclusive For ex var nextInst nextInDOM '.foo' '#item' will get you the first matching .foo after '#item' regardless of the DOM structure Check the original answer..