How to add class or id or CSS style in execCommand formatBlock 'p' tag?
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; } I got the