Whether it be a tab space, one regular space or many, jQuery cries Uncaught Error: Syntax error, unrecognized expression: <div></div>
Here's the code in jsFiddle: http://jsfiddle.net/dc8fK/
Here's the code:
console.log( $("<div></div>") ); // works
console.log( $(" <div></div>") ); // not
Aside from searching and removing any prefixed white space, is there a better, more official way of dealing with this?
You should call $.parseHTML()
, which can parse arbitrary HTML strings.