How to use js to count the number of page tags

php中世界最好的语言
Release: 2018-05-31 14:28:02
Original
3099 people have browsed it

This time I will show you how to use js to count the number of page tags, and what are the precautions for using js to count the number of page tags. The following is a practical case, let's take a look.

The specific code is as follows:

function fold(node){
      var map = new Map();
      map.set(node.tagName,1);
      [].reduce.call(node.children,(acc,child)=>{
        deal(acc,fold(child));
        return acc
      },map)
      return map
    }
    function deal(srcMap,tarMap){
      tarMap.forEach((value,tagName)=>{
        var newV = value + ~~srcMap.get(tagName);
        srcMap.set(tagName,newV);
      })
    }
Copy after login
Calling

I believe you have mastered the method after reading the case in this article, please come for more exciting information Pay attention to other related articles on php Chinese website!

Recommended reading:

How to use React virtual DOM

##Implement uploading images with backend code in WeChat applet

The above is the detailed content of How to use js to count the number of page tags. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!