Sunday, June 2, 2024
 Popular · Latest · Hot · Upcoming
71
rated 0 times [  74] [ 3]  / answers: 1 / hits: 52826  / 12 Years ago, thu, march 15, 2012, 12:00:00

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

More From » html

 Answers
263

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.


[#86819] Wednesday, March 14, 2012, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
dylondaytond

Total Points: 92
Total Questions: 88
Total Answers: 96

Location: China
Member since Fri, Jan 15, 2021
3 Years ago
dylondaytond questions
Tue, Jun 22, 21, 00:00, 3 Years ago
Thu, May 7, 20, 00:00, 4 Years ago
;