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
Node type constants aren't defined in IE, so in your code there
Node.TEXT_NODE
is undefined not3
as it should be. Essentially, in IE < 9, your filter is asking3 == undefined
, which obviously is false.See: How does one access the Node Type Constants in IE for workarounds.