[英]how i can put <script> in double quote
I'm trying to add the script
tag using JavaScript.我正在尝试使用 JavaScript 添加
script
标记。 I'm putting the tag into double quote.我将标签放入双引号中。 My problem is something else but solves with this simple example:
我的问题是别的,但用这个简单的例子解决了:
<script>
document.write("<script>" + example_var + "<\/script>");
</script>
How can I fix it?我该如何解决?
You can use two ways Template Literals您可以使用两种方式模板文字
document.write(`"<script>"${example_var}"<\/script>"`);
Single Quotes单引号
document.write('"<script>"' + example_var + '"<\/script>"');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.