N
N
number12017-06-12 20:28:02
JavaScript
number1, 2017-06-12 20:28:02

How to put the contents of a tag into a JS variable?

We need to parse the content of the page and output the content of the front tag c id to a string variable. How to do it?

(function(){
var http = new XMLHttpRequest();  
      http.open('GET', '');
      http.onreadystatechange = function () {
        if (this.readyState == 4 && this.status == 200) {
          var doc = new DOMParser().parseFromString(this.responseText, "text/html"); 
          var badge_text = doc.getElementById('stat').innerHTML;
          badge_text.toString();
        }
        }
      http.send(null);

      chrome.browserAction.setBadgeText({text: badge_text});

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question