【问题标题】:how can i select and highlight outerText from contenteditable tag如何从 contenteditable 标记中选择并突出显示外文本
【发布时间】:2021-09-18 12:58:27
【问题描述】:

我有一个 contenteditable P,我如何从 Div 中选择和突出显示外部文本

我的鼠标焦点从“selectionstart”开始,但我无法将焦点结束在“selectionend”上

<div> <p contenteditable ="true">selectionStart</p> </div> selectionEnd

【问题讨论】:

    标签: javascript c# html internet-explorer


    【解决方案1】:

    选择带有document.querySelector('p')p 标记并获取其outerText 属性:

    console.log(document.querySelector('p').outerText);
    &lt;div&gt; &lt;p contenteditable ="true"&gt;selectionStart&lt;/p&gt; &lt;/div&gt; selectionEnd

    【讨论】:

    • 对不起,我没有详细描述我的问题,我的鼠标焦点是从“selectionstart”开始的,但我不能把焦点放在“selectionend”上
    猜你喜欢
    • 2011-11-21
    • 1970-01-01
    • 2010-10-24
    • 2013-02-05
    • 2011-09-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多