js选中指定dom文本
1function selectAll(id) { 2 var h = document, 3 i = h.getElementById(id), 4 d, 5 g; 6 if (h.body.createTextRange) { 7 d = document.body.createTextRange(); 8 d.moveToElementText(i); 9 d.select(); 10 } else { 11 if (window.getSelection) { 12 g = window.getSelection(); 13 d = document.createRange(); 14 d.selectNodeContents(i); 15 g.removeAllRanges(); 16 g.addRange(d); 17 } 18 } 19}