html,js div开启contenteditable属性可编辑时,按回车键会出现div,如何禁止生成
div开启contenteditable属性时,当前div变成了一个可编辑的状态,按下回车键会生成一个div,如何禁止生成:方案一:让改元素以下只显示文本就不会显示其他标签了.read-write-plaintext-only { //纯文本-webkit-user-modify: read-write-plaintext-only;}方案二:通过jquery的事件,手动生成标签$('#chat_
·
div开启contenteditable属性时,当前div变成了一个可编辑的状态,按下回车键会生成一个div,如何禁止生成:
方案一:让改元素以下只显示文本就不会显示其他标签了
.read-write-plaintext-only { //纯文本
-webkit-user-modify: read-write-plaintext-only;
}
方案二:通过jquery的事件,手动生成标签
$('#chat_editor[contenteditable]').keydown(function(e) {
if (e.keyCode === 13) {
document.execCommand('insertHTML', false, '<br><br>');
return false;
}
});
更多推荐
所有评论(0)