Javascript 在html字符串中查找大量标记
例如,使用正则表达式:Javascript 在html字符串中查找大量标记,javascript,jquery,html,find,Javascript,Jquery,Html,Find,例如,使用正则表达式: OUTPUT: 2 console.log(findnumberoftags.match(//g.length); 使用正则表达式,例如: OUTPUT: 2 console.log(findnumberoftags.match(//g.length); 将字符串作为jquery对象,然后可以使用jquery方法来计算标记数 console.log( findnumberoftags.match( /<h2>/g ).length ); var find
OUTPUT: 2
console.log(findnumberoftags.match(//g.length);
使用正则表达式,例如:
OUTPUT: 2
console.log(findnumberoftags.match(//g.length);
将字符串作为jquery对象,然后可以使用jquery方法来计算标记数
console.log( findnumberoftags.match( /<h2>/g ).length );
var findnumberoftags=“hihihone two 我是最好的yes”;
警报($(findnumberoftags.filter(“h2”).length)
将字符串作为jquery对象,然后可以使用jquery方法来计算标记数
console.log( findnumberoftags.match( /<h2>/g ).length );
var findnumberoftags=“hihihone two 我是最好的yes”;
警报($(findnumberoftags.filter(“h2”).length)