index.html:
<html>
<head>
<title>chapter 5</title>
<script src="jquery.js"></script>
<script src="app.js"></script>
</head>
<body>
<div >
<p>this is a paragraph</p>
</div>
</body>
</html>
app.js:
$(function() {
$("div").on("hover", function(event) {
if(event.type === "mouseenter") {
$(this).css("background", "blue");
}
else {
$(this).css("background", "red");
}
});
});
so according to my Jquery: when I bring mouse over to tags it should change its colour to red and when any other even inside tag except mouse enter it should change to blue. But nothing is happening?
I have tried other functions with event which works fairly well I can not understand why this one is not working do I have to do something with "css" maybe?
mouseenterfrom the beginning. Keep in mind to not add overhead such as that in your code