jquery count elements with attribute

前端 未结 3 1664
南笙
南笙 2020-12-10 11:58

Can I count the number of elements with a specific attribute?

For example all the images with the src attribute test.gif

3条回答
  •  星月不相逢
    2020-12-10 12:58

    if you want to check the presence of the attribute only

    $('img[src]').length //or .size() 
    

提交回复
热议问题