Javascript 计数没有名称或ID的通用DIV标记
如何使用javascript计算DIV标记的数量?唯一的属性将始终是style=font系列:Courier New 页面中还有其他DIV。我只是想针对那些拥有style=font家族的人:Courier New;Javascript 计数没有名称或ID的通用DIV标记,javascript,html,css,Javascript,Html,Css,如何使用javascript计算DIV标记的数量?唯一的属性将始终是style=font系列:Courier New 页面中还有其他DIV。我只是想针对那些拥有style=font家族的人:Courier New; 有什么帮助吗?您可以使用jQuery: console.log($("[style='font-family:Courier New;']").length); 您正在寻找querySelectorAll var courier=document.queryselectoral'
有什么帮助吗?您可以使用jQuery:
console.log($("[style='font-family:Courier New;']").length);
您正在寻找querySelectorAll
var courier=document.queryselectoral'div[style=font-family:courier-New;];
对于var i=0,len=courier.length;iconsole.log($("[style='font-family:Courier New;']").length);