标签:ring replace get sel win log ace trim class
替换html中选中的文字
function replaceSelection() { if (window.getSelection) { var selecter = window.getSelection(); var selectStr = selecter.toString(); if (selectStr.trim != "") { var rang = selecter.getRangeAt(0); var temp = $("<b>" + selectStr + "<b/>"); rang.surroundContents(temp[0]); } } else if (document.selection) {//ie var selecter = document.selection.createRange(); selecter.select(); var selectStr = selecter.text; selecter.pasteHTML("<b>" + selectStr + "<b/>"); } }
标签:ring replace get sel win log ace trim class
原文地址:http://www.cnblogs.com/guohu/p/6178577.html