日期:2014-05-16 浏览次数:20419 次
<body> <input type="text" id="t" onselect="os(event)"/> <script language="javascript"> os = function(event){ event = event || window.event; var which = event.currentTarget || event.srcElement; var sv = which.value.substring(which.selectionEnd,which.selectionStart); alert( which.value.indexOf(sv) ); } </script> </body>