【发布时间】:2014-02-19 03:28:44
【问题描述】:
我正在努力添加大量的 html 代码。我找到了这个答案How To Append (Or Other Method) a Lot of HTML Code?,但我得到了一个非法参数错误。谁能建议一个更好的方法来管理这个?
JS
$(function() {
$("a").click(function() {
$("body").append(codeBlock);
});
});
var codeBlock = $("<div class='code-block'>\
<div class='select-event'>\
<label>Start</label>\
<select>\
<option>when the Run button is pressed</option>\
<option>when the object is pressed</option>\
<option data-option='keyoption'>when a keyboard key is pressed</option>\
</select>\
<span class='key-press-wrapper'>\
<label>Key</label>\
<input id='keyPress' placeholder='Press Key'>\
</span>\
</div>\
<div class='insert-block'>\
<label>Insert code blocks here</label>\
<ul id='sortable' class='connectedSortable'></ul>\
</div>\
</div>\");
【问题讨论】:
-
您不需要在“codeBlock”周围加上引号。
$('body').append(codeblock) -
已修改,感谢您的快速定位
-
这不是一个巨大的html。
标签: javascript jquery html