首页 > 其他 > 详细

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

时间:2018-05-07 21:26:09      阅读:190      评论:0      收藏:0      [点我收藏+]
<!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>

 

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

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!