Last element in .each() set

后端 未结 3 484
陌清茗
陌清茗 2020-12-02 22:14

I have an issue, where by I am doing a simple form validation, that needs some custom stuff that the validation plugin could not do for me. Basically, I have a name, email a

3条回答
  •  南笙
    南笙 (楼主)
    2020-12-02 22:44

    A shorter answer from here, adapted to this question:

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

    Just for completeness.

提交回复
热议问题