我想替换侧脚本标记中的 jQuery 函数。我在</body>
标签之前的布局中有这个 jQuery 函数。
<div id="white_backstretch">
<script>
$.backstretch("/body-bg.jpg");
</script>
</div>
在另一个页面(显示页面)上,我有:
<script>
$('#white_backstretch').replaceWith("<script>" + $.backstretch(<%= @white_label.logo %> + "</script>");
</script>
在这里,我试图替换现有的
<script>$.backstretch("/body-bg.jpg");</script>
和
<script>$.backstretch(<%= @profile.logo %></script>
这样当不同的页面出现时,背景图像就会改变。但我面临的问题是:
<script>
$('#white_backstretch').replaceWith("<script>" + $.backstretch(/uploads/white/logo/4/image14.png) + "</script>");
Uncaught SyntaxError: Unexpected token ILLEGAL
替换函数中的第一个结束</script>
标记被视为脚本的结尾,因此“);” <-- 作为意外令牌错误抛出
那么,如果有人告诉我如何用另一种 jQuery 方法替换脚本标签内的 jQuery 方法,那将会很有帮助?(此方法也应该在脚本标记内,因为我想在 html 文件中使用 replaceWith jQuery 方法)