I'm trying to get the css style of the text selection when user select only 1 row .
This is my code which works for multiple lines selection case:
var selectedDivs = window.selection().getRangeAt(0).cloneContent().children
// Then I can get css style from selectedDivs
But for single line selection , the selectedDivs
is always []
. How can I get the css style in this case? I've tried startContainer & endContainer of range but it didn't work.
startContainer
parentNode
应该为您提供所需的内容。
window.getSelection().getRangeAt(0).startContainer.parentNode
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.