Search code examples
jqueryhovermouseenter

Jquery:Mouseenter/Mouseleave with IE8 and Jquery 1.8


I'm trying to add a border bottom in Jquery and this block of code does not work :

$('div#tableContent div.slot div.desc h2 a').on(function() {
    $(this).css("border-bottom","1px solid #FFF");
});

$('div#tableContent div.slot div.desc h2 a').mouseleave(function() {
     $(this).css("border-bottom","none");
});

Is it because i'm using Jquery 1.8 and IE 8 ? thanks in advance for your help


Solution

  • You are missing the event type in your first code block here:

     .on('mouseenter', function() {
     //---^^^^^^^^^^^----this event type is missing
    

    Why bother to do this with js, you can achieve this with css:

    div#tableContent div.slot div.desc h2 a:hover{
       border-bottom : 1px solid #FFF;
    }