且构网

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

当我使用jQuery选择页面上的任何文本时,我将如何显示对话框?

更新时间:2023-02-11 14:43:06

您可以使用以下代码获取mouseup事件中的选定文本:

You can get the selected text on the mouseup event with some code like this:

$(document).mouseup(function (event) {
    var text = document.selection.createRange().text;
    if (text != "") {
        //Use text in popup, etc... SAMPLE:
        alert(text);
    }
});