鼠标经过选中元素内容

来源:互联网 发布:淘宝商城mp4 编辑:程序博客网 时间:2024/05/21 07:48
function copyTo(text) {
    if (document.body.createTextRange) {
        var range = document.body.createTextRange();
        range.moveToElementText(text);
        range.select();
    } else if (window.getSelection) {
        var selection = window.getSelection();
        var range = document.createRange();
        range.selectNodeContents(text);
        selection.removeAllRanges();
        selection.addRange(range);
    }

}



//

 onmouseover="copyTo(this);"


0 0