[英]How to have a PHP variable with HTML wrapped inside of JavaScript with both single quotes and double quotes already used
[英]How pass in JavaScript variable html with double and single quotes?
我正在尝试将 html 代码传递给包含双引号和单引号的变量,我尝试在 html 脚本标签中执行此操作,除 IE11 外一切正常
<script>
const partials = {
header: `
<div class="class-name">
<div class="child" data-with-single-quotes=''></div>
</div>
`
}
</script>
我怎样才能将这样的 html 放入 IE11 中的变量中,但仍然不使用 escaping 像\"
并且不通过+
加入
试试这个使用单引号而不是反引号。
<script>
const partials = {
header: '<div class="class-name">\
<div class="child" data-with-single-quotes=\'\'></div></div>'
}
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.