如何在append()中破坏html?
我可以使用任何技巧来破坏 append()
中的 html 吗?
例如,像这样的事情就太棒了!
// Append a popup for displaying the security checking form.
$(document.body).append("
<div id='popup-result' class='popup-outer'>
<div class='popup-inner'>
<div class='close'><a href='#' class='button-close'>x close</a></div>
<div class='respond-message'></div>
<div class='form-confirm'></div>
</div>
</div>");
这样我就不必在一行中编写 html - 很难阅读和调试!
Any trick I can use to break the html in append()
?
For instance, something like this would be great!
// Append a popup for displaying the security checking form.
$(document.body).append("
<div id='popup-result' class='popup-outer'>
<div class='popup-inner'>
<div class='close'><a href='#' class='button-close'>x close</a></div>
<div class='respond-message'></div>
<div class='form-confirm'></div>
</div>
</div>");
so that I don't have to do the html in one line - it's difficult to read and debug!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你有两个选择。您可以使用新行文字语法:
这可行,但可能会混淆一些 IDE(我上次尝试时 Visual Studio 就是这样做的。或者,如果您实际上不需要新行,您可以将每一行设为自己的字符串并连接字符串) :
You have two options. You can use the new line literal syntax:
This works, but may confuse some IDEs (Visual Studio does that last time I tried it. Or you can make each line it's own string and concatenate the strings if you don't actually want new lines: