jquery: reverse an order

前端 未结 5 1129
执念已碎
执念已碎 2021-02-05 20:47

How can I reverse an order with jquery?

I tried with the suggestion like this but it won\'t work!

$($(\".block-item\").get().reverse()).each(function() {         


        
5条回答
  •  太阳男子
    2021-02-05 21:22

    try this:

    function disp(divs) {
          var a = [];
          for (var i = 0; i < divs.length; i++) {
            a.push(divs[i].innerHTML);
          }
        alert(a);
        }
    
        disp( $("div.block-item").get().reverse() );
    

    DEMO

提交回复
热议问题