The
innerHTML
property returns a
string
. Strings do not have a "
document
" property.
Even if they did, you don't want to fetch all of the
<span>
elements in the document; you want the elements within the specific
<div>
.
Also,
getElementsByTagName
returns a collection of elements, which doesn't have a property called
innerText
.
Try calling
getElementsByTagName
on the
<div>
element:
var divs = document.getElementsByClassName("well-sm");
for (var i = 0; i < divs.length; i++) {
var div = divs[i];
var span = div.getElementsByTagName("span")[0];
if (span) {
var strText = span.innerText;
...
}
}