TEXT_NODE in IE < 9 jQuery problems

611 Views Asked by At

I have this simple function to find "unwrapped" text and wrap it into a div.

It is working fine apart from IE < 9. What can I change here to make it working please.

$('#categories_list') .contents() .filter(function() { return this.nodeType == Node.TEXT_NODE; }).wrap("");

Many thanks in advance.

Dom

1

There are 1 best solutions below

0
On BEST ANSWER

Node type constants aren't defined in IE, so in your code there Node.TEXT_NODE is undefined not 3 as it should be. Essentially, in IE < 9, your filter is asking 3 == undefined, which obviously is false.

See: How does one access the Node Type Constants in IE for workarounds.