var text = elem.innerText || elem.textContent || '';
var elem = { innerText: '' }; var text = elem.innerText || elem.textContent; alert(text);