Home >>jQuery Tutorial >jQuery mouseout() Method
jQuery mouseout() method in jQuery is used to add a function or triggers the mouseout event to run when the mouse pointer leaves the selected elements.
Syntax:Trigger the mouseout event for the selected elements:
$(selector).mouseout()
Attach a function to the mouseout event:
$(selector).mouseout(function)
Parameter | Description |
---|---|
function | It is an optional parameter and is used to specifies the function to run when the mouseout event is triggered |
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$(".txt1").mouseover(function(){
$(".txt1").css("background-color", "orange");
});
$(".txt1").mouseout(function(){
$(".txt1").css("background-color", "lightgreen");
});
});
</script>
</head>
<body>
<p class="txt1">Move the mouse pointer over me !</p>
</body>
</html>
Move the mouse pointer over me !