Monday, November 3, 2008

Solution to the InnerText Not work with Firefox

function getText(el)
{
if ('string' == typeof el.textContent) return el.textContent;
if ('string' == typeof el.innerText) return el.innerText;
return el.innerHTML.replace(/<[^>]*>/g,'');
}

function setText(el,str)
{
if ('string' == typeof el.textContent)
el.textContent = str;
if ('string' == typeof el.innerText)
el.innerText = str;

}

No comments: