<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns=""><head> <title>腾讯微博</title> <script src="JQuery/jquery-1.8.2.js" type="text/javascript"></script> <script type="text/javascript"> //文字选中代码 $.fn.selectRange = function (start, end) { var curObj = $(this).get(0); //获取当前选中 if (!curObj) return; //非curObj对象,返回. else if (curObj.setSelectionRange) { //设置属性. curObj.focus(); curObj.setSelectionRange(start, end); } /* WebKit */ else if (curObj.createTextRange) { // 创建TextRange var range = curObj.createTextRange(); range.collapse(true); range.moveEnd('character', end); range.moveStart('character', start); range.select(); } /* IE */ else if (curObj.selectionStart) { curObj.selectionStart = start; curObj.selectionEnd = end; } };