【发布时间】:2014-06-21 09:38:22
【问题描述】:
当我尝试给出下面的代码以更改所选多行的margin-bottom 时,当时只有最后选择的行是更改其他行只是添加 p 标签而不是样式。可能是我无法集中所有选定的行。我为此尝试了下面的代码。
Javascript:
var selectedElement = null;
function singleline() {
document.execCommand('formatblock',false,'p')
selectedElement1 = window.getSelection().focusNode.parentNode;
selectedElement1.style.marginBottom = '10px';
}
HTML:
<input type="button" value="addMarginBottom" onclick="javascript:singleline();"/>
<div class="textcontent" contenteditable="true"></div>
我的问题是:如何聚焦所有选定的节点并添加这种样式?
【问题讨论】:
-
你能加个小提琴吗?
标签: jquery html contenteditable execcommand