jquery hover function
$( "td" ).hover(
() => { //hover
$(this).addClass("hover");
},
() => { //out
$(this).removeClass("hover");
}
);
//or
$( "td" )
.mouseover( () => {
$(this).addClass("hover");
})
.mouseout( () => {
$(this).removeClass("hover");
}
);
//or
$( "td" )
.mouseenter( () => {
$(this).addClass("hover");
})
.mouseleave( () => {
$(this).removeClass("hover");
}
);
0
0
$(document).ready(function() {
$("p").hover(function() {
$(this).css("background-color", "green");
}, function() {
$(this).css("background-color", "yellow");
});
});
Thank you!
0
0
4.17
6
$(".selector").on({
mouseenter: function () {
//stuff to do on mouse enter
},
mouseleave: function () {
//stuff to do on mouse leave
}
});
Thank you!
6
0
3.33
3
$( "div.enterleave" )
.mouseenter(function() {
n += 1;
$( this ).find( "span" ).text( "mouse enter x " + n );
})
.mouseleave(function() {
$( this ).find( "span" ).text( "mouse leave" );
});
Thank you!
3
0
0
0
$( selector ).mouseenter( handlerIn ).mouseleave( handlerOut );
Thank you!
0
0
3.83
6
$("#p1").hover(function(){
alert("You entered p1!");
},
function(){
alert("Bye! You now leave p1!");
});
Thank you!
6
0
Are there any code examples left?
New code examples in category Javascript