【发布时间】:2018-12-08 18:59:33
【问题描述】:
我正在尝试通过单击按钮在文本区域内附加和前置一个 HTML 块,但它在 Internet Explorer 中不起作用。
$(document).ready(function () {
"use strict";
$('#export-file').click(function () {
document.getElementById("codeToSave").prepend('<!doctype html>\n<html> \n<head>');
document.getElementById("codeToSave").append($.trim('</body>\n</html>'));
});
});
<ul class="control-list">
<li class="controls" id="export-file" data-toggle="tooltip" title="Export " ><i class="fas fa-download"></i></li>
</ul>
<textarea id="codeToSave" disabled class="scrollStyle-3" ></textarea>
【问题讨论】:
-
你为什么不关闭你的标签?
-
Prepend 需要节点,而不是字符串。这可能是你问题的一部分。另外,你想做什么?我怀疑你做错了。
标签: javascript jquery html web web-applications