jquery 计数具有属性的元素 [英] jquery count elements with attribute
本文介绍了jquery 计数具有属性的元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以计算具有特定属性的元素的数量吗?
Can I count the number of elements with a specific attribute?
例如所有带有 src 属性 test.gif 的图像
For example all the images with the src attribute test.gif
推荐答案
使用 CSS 属性选择器对属性进行过滤
Use the CSS attribute selectors to filter on the attribute
$("img[src='test.gif']").length;
the size() and length both returns the number of elements matched;
这篇关于jquery 计数具有属性的元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文