Sum using jQuery each function without global variable

后端 未结 5 746
执念已碎
执念已碎 2021-01-14 03:47

I want to add some HTML elements that have the same class name.

So, the code will be like this with jQuery.

$(\".force\").each(function (){
    a +=          


        
5条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-14 04:29

    You can use $(".force").length, it returns the number of elements in the jQuery object.

    jQuery API

提交回复
热议问题