#13224 closed bug (notabug)
problem with backslashed multiline string
Reported by: | anonymous | Owned by: | |
---|---|---|---|
Priority: | undecided | Milestone: | None |
Component: | unfiled | Version: | 1.9.0 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
Creating element or sub-tree from a string, that writed in a few lines with backslashes at the line ends now gives a syntax error.
jQuery('\
<div></div>\
'); => Error: Syntax error, unrecognized expression: <div></div>
but
jQuery('<div></div>'); => [<div></div>]
Change History (3)
comment:2 Changed 11 years ago by
Resolution: | → notabug |
---|---|
Status: | new → closed |
comment:3 Changed 11 years ago by
Oh also, if you just want to have a literal string with newlines, try
jQuery($.trim('\ <div></div>\ '));
Note: See
TracTickets for help on using
tickets.
Use
$.parseHTML()
for those cases, it is much more lenient about what it parses and also lets you specify whether to process script tags. See the upgrade guide for an example, if you haven't read it already.http://jquery.com/upgrade-guide/1.9/#jquery-htmlstring-versus-jquery-selectorstring