How to Find Out Last Index of each() in jQuery?

后端 未结 6 1926
轻奢々
轻奢々 2020-12-24 06:45

I have something like this...

$( \'ul li\' ).each( function( index ) {

  $( this ).append( \',\' );

} );

I need to know what index will b

6条回答
  •  孤城傲影
    2020-12-24 07:10

    var arr = $('.someClass');
    arr.each(function(index, item) {
    var is_last_item = (index == (arr.length - 1));
    });
    

提交回复
热议问题