js 选择指定区域

/根据id 选择特定区域
function SelectRange(id) {

var div = document.getElementById(id);
var controlRange;
if (document.body.createControlRange) {
controlRange = document.body.createControlRange();
controlRange.addElement(div);
controlRange.execCommand('SelectAll');
}
else if (window.getSelection) {//标准浏览器
var sel = window.getSelection();
sel.selectAllChildren(div)
}
}

posted on 2019-04-17 16:59  gfbppy  阅读(569)  评论(0编辑  收藏  举报

导航