1

My hover() is not working. When I do click(), it works though:

$( "#testcard" ).on( "hover", 'tbody #thei', 
    function() {
    console.log("in");
  }, function(){
    console.log("out");
  });

This would work for me, so tomc's answer worked just fine for me.

j08691
  • 204,283
  • 31
  • 260
  • 272
AmazingDayToday
  • 3,724
  • 14
  • 35
  • 67

2 Answers2

0

I don't believe there is an .on('hover'), it's just .hover

$('tbody #thei').hover(
    function() {
        console.log("in");
    }, function() {
        console.log("out");
    }
);

http://jsfiddle.net/xk34xf8g/1/

If you're working with dynamic elements, you should use on.('mouseenter') and .on('mouseleave') instead.

$("#testcard")
    .on("mouseenter", "tbody #thei", function(event){
        console.log("in");
    })
    .on("mouseleave", "tbody #thei", function(event){
        console.log("out");
});

http://jsfiddle.net/xk34xf8g/2/

tomc
  • 417
  • 5
  • 17
0
$("p").hover(function(){
    $(this).css("background-color", "yellow");
    }, function(){
    $(this).css("background-color", "pink");
});

use above code it will solve the problem. For further knowledge about this visit this link. Click Here...

Ch Zunair
  • 1
  • 1