javascript jQuery:意外令牌非法
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16385492/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 04:26:29 来源:igfitidea点击:
jQuery: unexpected token ILLEGAL
提问by chuckfinley
could not find a solution to my problem so i'll ask here.
找不到我的问题的解决方案,所以我会在这里问。
When i insert jQuery file, i get an error on line 2: unexpected token ILLEGAL
当我插入 jQuery 文件时,在第 2 行出现错误:意外令牌非法
Code:
代码:
jQuery(document).ready(function(){
$('body').append('
<div id="style_selector">
<div id="style_selector_container">
// another chunk of code
</div><!-- #style_selector end -->');
});
Thank you in advance
先感谢您
回答by Deepu
jQuery(document).ready(function(){
$('body').append('<div id="style_selector"><div id="style_selector_container"></div>');
});
This will do the job.Because while you are appending a content using jquery it must not contains new line.
这将完成工作。因为当您使用 jquery 附加内容时,它不能包含新行。