Is hover a jquery event?

WBOY
Release: 2022-04-15 10:34:41
Original
2375 people have browsed it

Hover is a mouse event in jquery. The hover() method specifies two functions to be run when the mouse pointer hovers over the selected element. The first parameter specifies the function when the mouse pointer passes through the element, and the second parameter specifies the function when the mouse pointer leaves the element. Function, the syntax is "element object.hover(function, function)".

Is hover a jquery event?

The operating environment of this tutorial: windows10 system, jquery3.2.1 version, Dell G3 computer.

Is hover a jquery event?

Hover is a mouse event in jquery

The response of the page to different visitors is called an event.

Event handlers refer to methods that are called when certain events occur in HTML.

hover() method specifies two functions to be run when the mouse pointer hovers over the selected element.

Method triggers mouseenter and mouseleave events.

  • The mouseleave event occurs when the mouse pointer leaves the selected element.

  • The mouseenter event occurs when the mouse pointer passes through (enters) the selected element.

The syntax is:

$(selector).hover(inFunction,outFunction)
Copy after login

inFunction Required. Specifies the function to run when the mouseenter event occurs.

outFunction Optional. Specifies the function to run when the mouseleave event occurs.

The example is as follows:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>123</title>
<script src="js/jquery.min.js">
</script>
<script>
$(document).ready(function(){
  $("p").hover(function(){
    $("p").css("background-color","yellow");
    },function(){
    $("p").css("background-color","pink");
  });
});
</script>
</head>
<body>
<p>鼠标移动到该段落。</p>
</body>
</html>
Copy after login

Output result:

Is hover a jquery event?

Related video tutorial recommendation: jQuery video tutorial

The above is the detailed content of Is hover a jquery event?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!