且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

用另一个文本替换选定的

更新时间:2023-01-07 14:44:30

要获取HTML5中的当前选择,请使用 DOM Range API

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

要编辑选择,选择API

另请参阅:文本选择API在哪里?

如果你使用jQuery,那么使用 wrapSelection插件

If you use jQuery, then use the wrapSelection plugin