I've created an e-mail link that automatically populates the necessary information in the body. But, when I do .innerHTML I get a little more than I bargained for.
I want "March, 2012: 12-16"
What I get <B>March, 2012</B>: <FONT color=blue>12</FONT> - <FONT color=blue>16</FONT>
Is there a way to get the innerHTML without the html tags?
.value = undefined .text = undefined
Appending to innerHTML is not supported: Usually, += is used for appending in JavaScript. But on appending to an Html tag using innerHTML, the whole tag is re-parsed.
To set the value of innerHTML property, you use this syntax: element. innerHTML = newHTML; The setting will replace the existing content of an element with the new content.
Reading the HTML contents of an element Reading innerHTML causes the user agent to serialize the HTML or XML fragment comprised of the element's descendants. The resulting string is returned.
The use of innerHTML creates a potential security risk for your website. Malicious users can use cross-site scripting (XSS) to add malicious client-side scripts that steal private user information stored in session cookies.
You want .textContent
in all but older IE, and .innerText
in IE (<9).
So, try:
string = (node.textContent===undefined) ? node.innerText : node.textContent;
EDIT: Or, just use GGG's much cleaner string = (node.innerText || node.textContent)
, since undefined
is falsy.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With