Mouse Events in jQuery
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>jQuery Mouse Events</title>
<style>
body {
font-family: arial
}
#box {
background: pink;
padding: 10px;
border: 1px solid #000;
}
</style>
</head>
<body>
<!-- Mouse Events : click(), dblclick(), contextmenu(), mouseenter(), mouseleave() -->
<h1>jQuery Mouse Events</h1>
<div id="box" class="test">
<h2>Test Box</h2>
<p>Lorem ipsum dolor, sit amet consectetur adipisicing elit. Hic omnis eaque, molestiae temporibus sed
maiores eveniet ipsa blanditiis reiciendis error deserunt! Exercitationem doloremque quas saepe, magni omnis
tempore itaque animi.</p>
</div>
<script src="js/jquery-3.7.1.min.js"></script>
<script>
$(document).ready(function () {
$("#box").click(function () {
$("#box").css("background-color", "green");
$("h2").css("color", "white");
$("p").css("color", "white");
var a = $("#box").html();
console.log(a);
});
$("#box").dblclick(function () {
$("#box").css("background-color", "orange");
$("h2").css("color", "blue");
$("p").css("color", "blue");
});
$("#box").contextmenu(function () {
$("#box").css("background-color", "blue");
$("h2").css("color", "white");
$("p").css("color", "white");
});
$("#box").mouseenter(function () {
$("#box").css("background-color", "brown");
$("h2").css("color", "white");
$("p").css("color", "white");
});
$("#box").mouseleave(function () {
$("#box").css("background-color", "purple");
$("h2").css("color", "white");
$("p").css("color", "white");
});
});
</script>
</body>
</html>

Comments
Post a Comment