Jump to content

  • Free consultations and support
  • Live chatClick Here for Live Chat
  • Call ico 1888-906-1888
    Phone support: Open

    Ready for your call :)

    Our business hours:

    Mon — Fri, 2am — 8pm (EST)

    US & EU support teams

    Phone support: Closed

    We are back in: 1h 20m

    Our business hours:

    Mon — Fri, 2am — 8pm (EST)

    US & EU support teams


How to Loop through Elements Backwards in jQuery

backwards elements jquery loop

  • Please log in to reply
 

#1 SmartWeb

SmartWeb

    Senior Member

  • Designer
  • 271 posts

Posted 16 August 2012 - 10:02 AM

To loop through elements backwards in jQuery, use the below trick:


$(function(){

var reversedSet = $("li").get().reverse();

//get() will return an array of elements, and reverse() will reverse it

$(reversedSet).each(function(){

//this will put the reversed set ine each function.

});
});





Also tagged with one or more of these keywords: backwards, elements, jquery, loop

1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users