Patrik
Patrik

Reputation: 2247

Getting css with jquery and Internet Explorer

I'm trying to get some css with jquery in internet explorer.

The css is set in a external file and looks like this:

#something a {
    text-decoration: none;
    /* since I dont want underline when not hover */
}

#something a:hover {
    text-decoration: underline;
}

And I want to get if underline is set or not.

This works in firefox and webkit but not IE:

$('a').hover(function() {
    console.log($(this).css('textDecoration'));
    /* this return underline in FF and Webkit but not in IE */
});

Does anyone know how to get it to work in IE?

Upvotes: 0

Views: 191

Answers (4)

RoToRa
RoToRa

Reputation: 38400

Adding a setTimeout makes it work:

$("a").hover(function() {
    var x = $(this);
    setTimeout(function() {
      console.log(x.css("text-decoration"));
    }, 1);
});

http://jsfiddle.net/ZGKqC/2/

Upvotes: 1

Salman Riaz
Salman Riaz

Reputation: 83

Try following

$('a').hover(function() {
     console.log($(this).css('text-decoration'));         
});

Upvotes: 0

thecodeparadox
thecodeparadox

Reputation: 87073

Try this Bro:

$('a').css('textDecoration', 'none'); //initially set no underline 
$('a').mouseenter(function() {
    $(this).css('textDecoration', 'underline'); //set underline in hover in
}).mouseleave(function() {
    $(this).css('textDecoration', 'none'); // set no underline in hover out
});

Upvotes: 0

Anish
Anish

Reputation: 2917

try like this...

$('a').hover(function() {
    $(this).css('text-decoration','underline');
});

Upvotes: 0

Related Questions