Is there a way i can track how many <a href=""></a>
is in a specific div through jQuery ?
質問する
186 次
2 に答える
5
You can use length
property:
$('div#specific a').length;
If you want to know how many anchors with empty href and content exist you can use filter
method and :empty
selector:
$('div#specific a:empty').filter(function(){
return this.href === ""
}).length;
于 2012-10-12T23:12:26.180 に答える
0
You can use length as well as size also do :
But length is preferred (http://api.jquery.com/length/)
$('a').length
$('a').size();
Note: the .length property is preferred because it does not have the overhead of a function call (courtesy : http://api.jquery.com/size/ )
于 2012-10-12T23:15:25.933 に答える