好的,有些人会知道我的意思并编辑我的问题,但他们做错了。
更好的解释:
你有一个 contenteditablediv
的 text This is a Test String.
。如果你现在使用execCommand('underline')
你Test String
得到的,This is a <u>Test String</u>
如果你现在使用execCommand('strikethrough')
你is a Test
得到的This <s>is a <u>Test</u></s><u>String</u>
,这是正确的。
所以,在 HTML5<u>
中<s>
已经过时了。首先execCommand
,您可以使用surroundContents()
with a <span style="text-decoration:underline;">
。如果您现在surroundContets()
第二次使用 ,execCommand
您将收到BAD_BOUNDARYPOINTS_ERR
.
我想要的东西是一个函数,它execCommand
在这种情况下工作,但我可以用女巫 HTML-Tag 定义的函数将包裹字符串......(如果有任何重叠,它应该是智能的......)