本文介绍了如何在execCommand中添加class或id或CSS样式formatBlock'p'标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想用 execCommand('formatblock')
来选择一行符号< p>
标签或者< span>
在我的contentEditable < div>
(拥有自己的特定类或id或CSS样式富文本编辑器)。
document.execCommand('formatblock',false,'p'> ;;
解决方案如何在此代码中添加类或ID或CSS?方案如果您想在content editable div中添加CSS的id或class,那么您将使用下面的代码---
< script>
function CssFnctn()
{
document.execCommand('formatblock',false,'p')
var listId = window。 getSelection()。focusNode.parentNode;
$(listId).addClass(oder2);
}
< / script>
.oder2
{
padding-left:3em;
}
I want to use
execCommand('formatblock')
to select a line with the<p>
tag or<span>
with a specific class or id or any CSS style in my contentEditable<div>
(own rich text editor).document.execCommand('formatblock', false, 'p'>;
How can I add a class or id or CSS in this code?
解决方案If you want to add id or class for CSS in content editable div, then you will use below code---
<script> function CssFnctn() { document.execCommand('formatblock', false, 'p') var listId = window.getSelection().focusNode.parentNode; $(listId).addClass("oder2"); } </script> .oder2 { padding-left: 3em; }
这篇关于如何在execCommand中添加class或id或CSS样式formatBlock'p'标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!