我刚刚升级到1.9.1 经过一些技术缺陷后,所有工作都正常,除了:
var $newthumbs = $(' <div id=\"car-7\" class=\"thumbnail_car thumbnail span2\" data-sorting-top=\"2\" data-sorting-date=\"2013-01-12 16:47:31 UTC\"></div>');
如果我将此行放入 jquery 1.8.3 的控制台中,它会被接受,并且我可以使用 $newthumbs 检索它
在 1.9.1 中,它失败并显示 错误:语法错误,无法识别的表达式:
我已阅读changelog我没有看到任何相关的内容可以打破这一点。我可能对jquery了解不多,但这种语法看起来很标准。
什么改变了?
更新
我确实找到了这个here
HTML strings with leading whitespace: jQuery 1.9 restricts the strings processed by $() for security reasons. Although we recommend you use $.parseHTML() to process arbitrary HTML like templates, the 1.1.0 version of the Migrate plugin restores the old behavior.
最佳答案
如果删除空格,它将起作用:
var $newthumbs = $('<div id=\"car-7\" class=\"thumbnail_car thumbnail span2\" data-sorting-top=\"2\" data-sorting-date=\"2013-01-12 16:47:31 UTC\"></div>');
关于jquery - 在 jquery 1.9.1 中创建变量失败,在 1.8.3 中则不会,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14817039/