How do I extract the value 2083236893 from the following object using JavaScript?
<div class="gwt-Label">2083236893</div>
I installed Greasemonkey 3.17 for Firefox 52.2.1 (32-bit) and tested every code example provided and failed.
var html = document.getElementsByClassName("gwt-Label")[0];
alert(html.innerHTML);
The above example comes from: Accessing Div, by class name, with javascript.
Should the code be run on full download of the web page?
Appended:
var elements = document.getElementsByClassName("gwt-Label")[0];
alert(elements.innerHTML);
the above may fail if
elements.length = 0
It may be the case the document has not been loaded in full or query result = 0 - no DIV object contains class name from query string
Firebug can generate XPath to the selected object (innerHTML or innerTEXT) in the document (HTML version in your browser) to let you verify if the class name from the query is correct and exists.
Setting greater value for timeout may let HTML document to be loaded fully to make your script run via Greasemonkey or alike add-on to give correct results via
console.log(HTMLCollection.length)
see above.