javascript - How can I quickly count occurrences of a string on a webpage? -


Looking at a local URL, how quickly do I get the number of string abc on the page Can I count using javascript and / or jquery?

Example:

For given URL: How often can this code be on ABC (case insensitive)?

Answer:

  • 795 (count of HTML tags)
  • 455 (counting only visible text) < P> Does the same results of JavaScript and / or jQuery generate?

    You can do this in Konsole or in JavaScript on the page:

     < Code> $ ("*"). Html () Match (/ abc / gi) This will get you just text nodes on the page *:  
      var count = 0; $ ("Body") Content () Return to filter (function () {this.nodeType == 3} each (function () {var match = this.wholeText.match (/ abc / gi); if (match) count = match = lang;});   
    • The only issue I see is that the javascript code between the tags appears in the form of text nodes, so even if it's included in your script tags in your tag, Explores.

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -