Replacing selected with another text

前端 未结 2 910
我寻月下人不归
我寻月下人不归 2021-01-16 17:18

I am trying to replace selected text with another text.
Consider following is the line of text.

Hello world.Good morning. Hello world. Good mornin

2条回答
  •  无人共我
    2021-01-16 17:46

    To get the current selection in HTML5, use the DOM Range API.

    To edit the selection, the Selections API can be used.

    See also: Where did the Text Selection API go?

    If you use jQuery, then use the wrapSelection plugin

提交回复
热议问题