gpt4 book ai didi

javascript - 使用链接样式附加 DIV

转载 作者:太空宇宙 更新时间:2023-11-04 01:05:16 25 4
gpt4 key购买 nike

我有数百个 HTML 页面,我想为它们添加一个带有链接和样式的新 div,但编辑每个页面都需要很多时间。

所有页面都有一个共同的 JavaScript 文件。

我怎样才能将下面的 div 添加到所有页面?

<div  style="background-color:#561D1B;" id="testid">
<marquee style="background-color:#561D1B;height:19px;"><script src="https://testurl.com/test" type="text/javascript" ></script></marquee>
</div>

avoid-fout 是一个类,我尝试添加以下代码,但它不起作用。

$(".avoid-fout").append("<div  style="background-color:#561D1B;" id="testid">
<marquee style="background-color:#561D1B;height:19px;"><script src="https://testurl.com/test" type="text/javascript" ></script></marquee>
</div>");

最佳答案

附加时,请确保遵守单引号和双引号的使用,如下所示

$(".avoid-fout").append('<div style="background-color:#561D1B;" id="testid">
<marquee style="background-color:#561D1B;height:19px;"><script src="https://testurl.com/test" type="text/javascript" ></script></marquee>
</div>');

首先使用单引号,然后里面的所有内容都应该使用双引号,反之亦然。

关于javascript - 使用链接样式附加 DIV,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52353351/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com