jQuery mouse event mousemove() event

mousemove() event

The mousemove event occurs when the mouse pointer moves within the specified element.

Note: When the user moves the mouse one pixel, a mousemove event will occur. Handling all mousemove events consumes system resources. Please use this event with caution.

Let’s write an example below:

We have a div tag, given a width, height, border, and a p tag. When the mouse moves inside the div tag, the elements in the p tag The color changes

The code is as follows:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>mousemove()事件</title>
    <style type="text/css">
        div{
            width:200px;
            height:200px;
            border:1px solid #000;
        }
    </style>
    <script src="http://libs.baidu.com/jquery/1.9.1/jquery.js"></script>
</head>
<body>
    <div></div>
    <p>php 中文网</p>

    <script>
        $("div").mousemove(function(){
            $('p').css('color','red');
        })
    </script>
</body>
</html>


Continuing Learning
||
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>mousemove()事件</title> <style type="text/css"> div{ width:200px; height:200px; border:1px solid #000; } </style> <script src="http://libs.baidu.com/jquery/1.9.1/jquery.js"></script> </head> <body> <div></div> <p>php 中文网</p> <script> $("div").mousemove(function(){ $('p').css('color','red'); }) </script> </body> </html>
submitReset Code