[英]Getting css with jquery and Internet Explorer
I'm trying to get some css with jquery in internet explorer.我正在尝试在 Internet Explorer 中使用 jquery 获取一些 css 。
The css is set in a external file and looks like this: css 设置在外部文件中,如下所示:
#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:这适用于 firefox 和 webkit 但不适用于 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?有谁知道如何让它在 IE 中工作?
Adding a setTimeout
makes it work:添加
setTimeout
使其工作:
$("a").hover(function() {
var x = $(this);
setTimeout(function() {
console.log(x.css("text-decoration"));
}, 1);
});
try like this...试试这样...
$('a').hover(function() {
$(this).css('text-decoration','underline');
});
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
});
Try following尝试关注
$('a').hover(function() {
console.log($(this).css('text-decoration'));
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.