JS中如何取得某个属性的值出现了多少次?

日期:2016-03-19 05:44:45 人气:1

JS中如何取得某个属性的值出现了多少次?

var divs = document.getElementsByTagName('div'); var count = 0; for(var i=0;i<divs.length;i++) { if(divs[i].getAttribute('name') == 'ac') { count++; } } alert(count)
    A+
热门评论