Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在html字符串中查找大量标记_Javascript_Jquery_Html_Find - Fatal编程技术网

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=“hihih

  • one
  • two
  • 我是最好的

    yes”; 警报($(findnumberoftags.filter(“h2”).length)

    将字符串作为jquery对象,然后可以使用jquery方法来计算标记数

    console.log( findnumberoftags.match( /<h2>/g ).length );
    
    var findnumberoftags=“hihih

  • one
  • two
  • 我是最好的

    yes”; 警报($(findnumberoftags.filter(“h2”).length)