【发布时间】:2016-03-20 08:01:05
【问题描述】:
当按钮在内容可编辑的 div 上执行 execCommand 时,是否有一种内置方法可以保持按钮处于活动状态?
示例:
<input type="button" onclick="doRichEditCommand('bold');" value="B"/>
function doRichEditCommand(command){
document.execCommand(command, null, false);
}
我希望我的按钮在 carret 位于已应用 document.execCommand(command, null, false); 的区域内时保持活动状态。我想通过检查父元素是可行的,但如果有内置的方法会更好。
换句话说,我希望我的粗体按钮是橙色的,而 carret 应该是粗体的。
【问题讨论】:
标签: javascript html wysiwyg contenteditable rich-text-editor