Saturday, February 23, 2013

Reverse selected elements in jQuery

You can reverse the selected elements in jQuery using get and reverse methods.  
Just use get and reverse with any jQuery selectors like  
$($("ANY_JQUERY_SELECTOR").get().reverse())
For example   
$("tr") 
Will select all tr elements in order of appearance while
$($("tr").get().reverse())
will select the elements in reverse order of appearance.  

Live Demo.

No comments:

Post a Comment