Does any one know innerText alternative of a span in mozilla?
My span is
<span id='cell1'></span>
and the javascript is
document.getElementById('cell1').innerText = 'Tenelol';
But Mozilla is not supporting this!!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
innerTextis a proprietary IE thing. The W3C definestextContentas the official property.An easy way is to exploit the
||logical operator and its short circuiting nature, as well as JavaScript returning the last evaluated value in a condition (most times the truthy operand).jsFiddle.
(Note in the fiddle I checked for the
innerTextfirst. This was only because most people on here do not use IE. IRL, check fortextContentfirst, and fallback toinnerText.)