Получение CSS с JQuery и Internet Explorer - PullRequest
0 голосов
/ 31 мая 2011

Я пытаюсь получить некоторые CSS с JQuery в Internet Explorer.

CSS установлен во внешнем файле и выглядит так:

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

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

И я хочу получить, установлено ли подчеркивание или нет.

Это работает в Firefox и WebKit, но не в IE:

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

Кто-нибудь знает, как заставить его работать в IE?

Ответы [ 4 ]

1 голос
/ 31 мая 2011

Добавление setTimeout заставляет его работать:

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

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

0 голосов
/ 31 мая 2011

Попробуйте это, братан:

$('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
});
0 голосов
/ 31 мая 2011

Попробуйте выполнить

$('a').hover(function() {
     console.log($(this).css('text-decoration'));         
});
0 голосов
/ 31 мая 2011

попробуй вот так ...

$('a').hover(function() {
    $(this).css('text-decoration','underline');
});
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...