InnerText and textConent usage in javascript

Thursday, June 20, 2013
Now there major browsers always have some stuff different to make life of web developer horrible. On XP with latest IE, InnerText and textConent both work on chrome. Only textConent works Firefox whereas only InnerText works on Internet Explorer. So here is a con to make them work on all browsers.
if(document.all){
     document.getElementById('element').innerText = "my text";
} else{
    document.getElementById('element').textContent = "my text";
}
I haven't tested it on safari but I hope it work for all of you.

No comments: