My jquery code
It’s not working when
$("a").on("hover",function(){$(this).css("background","#ccc");},function(){$(this).css("background","#fff")});
But is working when
$("a").hover(function(){$(this).css("background","#ccc");},function(){$(this).css("background","#fff")});
How to make it to work with hover
In case of
.on()hover it will look likeBut for
.hover()is accept two functions first one formouseenterand second one formouseleave.So if you want to use
.on()then your code will:As @ThiefMaster comment if you want to bind
mouseenterandmouseleaveseparately then you can try:or using
.on()you can do