码迷,mamicode.com
首页 > 其他好文 > 详细

获取鼠标停留的位置和设置鼠标的停留的地方

时间:2018-05-07 21:44:43      阅读:169      评论:0      收藏:0      [点我收藏+]

标签:get   rip   test   style   utf-8   art   位置   back   org   

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
</head>
<body>
    <input type="text" style="width:700px" id="test1" name="test1" value="test12设置鼠标的停留的地方设置鼠标的停留的地方设置鼠标的停留的地方设置鼠标的停留的地方设置鼠标的停留的地方设置鼠标的停留的地方3" 
        onclick="getthis(this);" />
    <script>

        function getthis(obj)         //获取鼠标停留的位置
        {                                    
            var i = obj.selectionStart;
            var t = obj.selectionEnd;
        }
        function moveEnd(obj) {
            obj.focus();
     if (typeof obj.selectionStart == number
                    && typeof obj.selectionEnd == number) {
                obj.selectionStart = obj.selectionEnd = 1;   //设置鼠标的停留的地方
            }
        }
        moveEnd(document.getElementById("test1"))
    </script>


</body>
</html>

 

获取鼠标停留的位置和设置鼠标的停留的地方

标签:get   rip   test   style   utf-8   art   位置   back   org   

原文地址:https://www.cnblogs.com/imaye/p/9004954.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!