未捕获的语法错误:jQuery 字符串中意外的标记 ILLEGAL
Uncaught SyntaxError: Unexpected token ILLEGAL in jQuery string
$('#post-2233 > h2').text('Feeds / Downloads');
$('#post-2233 > h2').after(
'<div class="clo-column-before"> '
<p>Please login on the right to access the content below.</p> '
<p>Below is all the downloadable content on the website. Your account gives you access to all the items with a check mark next to it. </p> '
<p>You can purchase additional access from your <a href="http://www.chineselearnonline.com/amember/member.php">member page</a>. If you have any problems accessing any of the content below, please <a href="http://www.chineselearnonline.com/contact-us/">contact us</a>.</p> '
</div>'
);
$('#post-2233 > .entrytext').after(
'<div class="clo-column-after"> '
<h2>Download instructions: PC / Mac, iPhone / iPad, Android</h2> '
<h3>PC / Mac:</h3> '
<p>Click directly on the links to open the content. You can then download it directly from the page that opens.</p> '
<p>Click on the iTunes logo to open the content into iTunes.</p> '
<p>Note that the PDFs are in a zip archive that will need to extracted after download.</p>
</div>'
);
});
这是有问题的行:
<div class="clo-column-after"> '
不过,我没有看到任何奇怪的东西。
由于拆分多行字符串的方式,您的浏览器很可能在每个'
插入行尾字符,也许 jQuery 不喜欢这些字符。只是研究你的问题,我看到的几乎每篇文章都建议不要这种类型的分行。相反,您可以做几件事:
编辑:您在最后一行缺少<p>
'
。但是,我仍然会考虑以下更改之一。
-
只需使用常规字符串连接:
$('#post-2233 > .entrytext').after( '<div class="clo-column-after">' + '<h2>Download instructions: PC / Mac, iPhone / iPad, Android</h2>' + '<h3>PC / Mac:</h3>' + '<p>Click directly on the links to open the content. You can then download it directly from the page that opens.</p>' + '<p>Click on the iTunes logo to open the content into iTunes.</p>' + '<p>Note that the PDFs are in a zip archive that will need to extracted after download.</p>' + '</div>' );
-
使用模板:
<script id="dl-instructions" type="text/template"> <div class="clo-column-after"> <h2>Download instructions: PC / Mac, iPhone / iPad, Android</h2> <h3>PC / Mac:</h3> <p>Click directly on the links to open the content. You can then download it directly from the page that opens.</p> <p>Click on the iTunes logo to open the content into iTunes.</p> <p>Note that the PDFs are in a zip archive that will need to extracted after download.</p> </div> </script>
然后你的 jQuery
after()
调用变为:$('#post-2233 > .entrytext').after($('#dl-instructions').html());
相关文章:
- 使用 JSON.parse 将字符串(变量)转换为对象,错误意外标记
- “JSON.parse(str)”返回“意外令牌c”,但str是一个字符串
- 意外的令牌:用于Javascript中的JSON字符串
- 未捕获的语法错误:带有 .append() 字符串的意外标识符
- 生成动态 HTML,使用 JavaScript 更改名称值.错误:- 意外的字符串或标识符
- 在 JavaScript 中解析日期字符串的意外结果
- 未捕获的语法错误:jQuery 字符串中意外的标记 ILLEGAL
- 铬 - 意外令牌 非法.火狐和.字符串文字
- 将变量打印到控制台时出现意外字符串:[对象窗口]
- 创建视区会导致未捕获的语法错误:意外的字符串错误
- append() jquery中意外的字符串
- 尝试将一个元素加载到另一个元素时出现意外字符串
- 意外字符串,What'这段代码错了
- 未捕获的语法错误意外字符串
- 在JS和CSS中出现意外字符串
- 流星选择器不工作,出现意外字符串错误
- 输出文本文件时出现意外字符串
- 未捕获的语法错误:我的JavaScript中出现意外字符串
- 未捕获的语法错误:我的 Javascript 代码中出现意外字符串
- 意外字符串常量