xylw 发表于 2013-2-7 19:36:52

js获得光标所在的文本框(text/textarea)中的位置

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><head>    <title>无标题页</title></head><body>    <form name="form1" method="post"id="form1">      <a href="javascript:" >用户名</a><br>      <textarea name="txtTemp" rows="2" cols="20" id="txtTemp"style="height:320px;width:700px;"></textarea>                                                                  </form></body></html> <script type="text/javascript">function SetContent(text){ txtTemp.focus(); var sel = document.selection.createRange(); sel.text=text;}   function onblurAction() {    txtTemp = event.srcElement;} </script>
页: [1]
查看完整版本: js获得光标所在的文本框(text/textarea)中的位置