Let us see the important mouse events provided by JQuery.
<html>
<head>
<title> My First Programme </title>
</head>
<body>
<h1> JQuery </h1>
<p class = "para1"> First Paragraph </p>
<p class = "para2"> Second Paragraph </p>
<p class = "para3"> Third Paragraph </p>
<button> Click me </button>
<script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"> </script>
<script>
$('button').click( function() {
$('p').text("All the contents of p element got replaced")
});
</script>
</body>
</html>
<html>
<head>
<title> My First Programme </title>
</head>
<body>
<h1> JQuery </h1>
<p class = "para1"> First Paragraph </p>
<p class = "para2"> Second Paragraph </p>
<p class = "para3"> Third Paragraph </p>
<img src = "/myImage.png" alt = "Double Click me"/>
<script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"> </script>
<script>
$('img').dblclick( function() {
$('p').text("All the contents of p element got replaced")
});
</script>
</body>
</html>
<p class = "para1"> First Paragraph </p> <p class = "para2"> Second Paragraph </p> <p class = "para3"> Third Paragraph </p>
<img src = "/myImage.png" alt = "Double Click me"/>
$('img').dblclick( function() {
$('p').text("All the contents of p element got replaced")
});$('img')$('img').dblclick(...)$('img').dblclick( function() {
$('p').text("All the contents of p element got replaced")
});<html>
<head>
<title> My First Programme </title>
</head>
<body>
<h1> JQuery </h1>
<p class = "para1"> First Paragraph </p>
<img src = "/myImage.png" alt = "Bring the mouse pointer here"/>
<script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"> </script>
<script>
$('img').hover(
function() {
$('p').text("Mouse pointer is in the image")
}, function() {
$('p').text("The Mouse pointer is outside the image")
}
);
</script>
</body>
</html>
<p class = "para1"> First Paragraph </p>
<img src = "/myImage.png" alt = "Bring the mouse pointer here"/>
$('img').hover(
function() {
$('p').text("Mouse pointer is in the image")
}, function() {
$('p').text("The Mouse pointer is outside the image")
}
);$('img')$('img').hover(...)$('img').hover(
function() {
$('p').text("Mouse pointer is in the image")
}, function() {
$('p').text("The Mouse pointer is outside the image")
}
);function() {
$('p').text("Mouse pointer is in the image")
}'Mouse pointer is in the image'
function() {
$('p').text("The Mouse pointer is outside the image")
}'The Mouse pointer is outside the image'
<html>
<head>
<title> My First Programme </title>
</head>
<body>
<h1> JQuery </h1>
<p class = "para1"> First Paragraph </p>
<img src = "/myImage.png" alt = "Bring the mouse pointer here"/>
<script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"< </script>
<script>
$('img').mouseenter( function() {
$('p').text("Mouse pointer is in the image")
});
</script>
</body>
</html>
<p class = "para1"> First Paragraph </p>
<img src = "/myImage.png" alt = "Bring the mouse pointer here"/>
$('img').mouseenter( function() {
$('p').text("Mouse pointer is in the image")
});$('img')$('img').mouseenter(...)$('img').mouseenter( function() {
$('p').text("Mouse pointer is in the image")
});function() {
$('p').text("Mouse pointer is in the image")
}'Mouse pointer is in the image'
<html>
<head>
<title> My First Programme </title>
</head>
<body>
<h1> JQuery </h1>
<p class = "para1"> First Paragraph </p>
<img src = "/myImage.png" alt = "Bring the mouse pointer here"/>
<script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"> </script>
<script>
$('img').mouseleave( function() {
$('p').text("Mouse pointer left the image")
});
</script>
</body>
</html>
<p class = "para1"> First Paragraph </p>
<img src = "/myImage.png" alt = "Bring the mouse pointer here"/>
$('img').mouseleave( function() {
$('p').text("Mouse pointer left the image")
});$('img')$('img').mouseleave(...)$('img').mouseleave( function() {
$('p').text("Mouse pointer left the image")
});function() {
$('p').text("Mouse pointer left the image")
}'Mouse pointer left the image'
<html>
<head>
<title> My First Programme </title>
</head>
<body>
<h1> JQuery </h1>
<p class = "para1"> First Paragraph </p>
<img src = "/myImage.png" alt = "Bring the mouse pointer here"/>
<script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"> </script>
<script>
$('img').mousedown( function() {
$('p').text("You have pressed the mouse button")
});
</script>
</body>
</html>
<p class = "para1"> First Paragraph </p>
<img src = "/myImage.png" alt = "Bring the mouse pointer here"/>
$('img').mousedown( function() {
$('p').text("You have pressed the mouse button")
});$('img')$('img').mousedown(...)$('img').mousedown( function() {
$('p').text("You have pressed the mouse button")
});function() {
$('p').text("You have pressed the mouse button")
}'You have pressed the mouse button'
<html>
<head>
<title> My First Programme </title>
</head>
<body>
<h1> JQuery </h1>
<p class = "para1"> First Paragraph </p>
<img src = "/myImage.png" alt = "Bring the mouse pointer here"/>
<script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"> </script>
<script>
$('img').mouseup( function() {
$('p').text("You have released the mouse button")
});
</script>
</body>
</html>
<p class = "para1"> First Paragraph </p>
<img src = "/myImage.png" alt = "Bring the mouse pointer here"/>
$('img').mouseup( function() {
$('p').text("You have pressed the mouse button")
});$('img')$('img').mouseup(...)$('img').mouseup( function() {
$('p').text("You have released the mouse button")
});function() {
$('p').text("You have released the mouse button")
}'You have released the mouse button'
<html>
<head>
<title> My First Programme </title>
</head>
<body>
<h1> JQuery </h1>
Type Something : <input type = "text">
<script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"> </script>
<script>
$('input').focus( function() {
$(this).css("background-color", "yellow")
});
</script>
</body>
</html>
<input type = "text">
$('input').focus( function() {
$(this).css("background-color", "yellow")
});$('input')$('img').focus(...)$('input').focusin( function() {
$(this).css("background-color", "yellow")
});function() {
$(this).css("background-color", "yellow")
});<html>
<head>
<title> My First Programme </title>
</head>
<body>
<h1> JQuery </h1>
Type Something : <input type = "text">
<script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"> </script>
<script>
$('input').focus( function() {
$(this).css("background-color", "yellow")
});
$('input').blur( function() {
$(this).css("background-color", "red")
});
</script>
</body>
</html>
<input type = "text">
$('input').focus( function() {
$(this).css("background-color", "yellow")
});$('input').blur( function() {
$(this).css("background-color", "red")
});Next, let us look at the keyboard Events.