Monday 15 April 2013

javascript - How to check if property 'isElementContentWhitespace' is supported? -


I want to use on text nodes,
but not all browsers support it, so let me test it It is supported that it is
if it is, use it, if jquery $ $ trim does not apply ...

I tried to do something like that, on IE Not luck, good on FF:

  var testEl = document.createElement ('span'); TestEl.innerHTML = ''; Warning (testEl.firstChild.isElementContentWhitespace);  

OK, I have been able to test for this support!

  var testEl = document.createTextNode ('text'); Alert ('ElementContentWhitespace' in testEl);  

Works great in IE too ... :)


No comments:

Post a Comment