1

我在使以下代码在任何版本的 IE 中工作时遇到问题。应该显示的 div 根本不会出现在悬停上......

$('.trigger').hover(function() {
    $(this).css({'height':'390px','width':'475px'});
    $(this).find('.preview_window').css('left', '0px');
},
function(){
    $(this).css({'height':'29px','width':'29px'});
    $(this).find('.preview_window').css('left', '-9999px');
}
);

它必须是一些非常愚蠢的东西......看看它是如何在除 IE 之外的所有东西上工作的。任何人都可以解释一下吗?

4

3 回答 3

0

我认为您必须将 position 属性添加到该 div :

preview_window {
    position: relative;
}
于 2013-05-07T15:26:52.587 回答
0

原来 IE 只是不喜欢我在函数中放置换行符的位置......

这是 IE 显然可以更好地理解的更改代码。

$('.trigger').hover(function() {
    $(this).css({'height':'390px','width':'475px'});
    $(this).find('.preview_window').css('left', '0px');
},function(){ //This was also on two lines before
    $(this).css({'height':'29px','width':'29px'});
    $(this).find('.preview_window').css('left', '-9999px');
}); // This was on two lines before

我知道这是一件愚蠢的事情。现在一切正常。=/

于 2013-05-07T15:40:22.180 回答
0

您可能需要像这样专门定义位置方法:

$('.trigger').hover(function() {
    $(this).css({'height':'390px','width':'475px'});
    $(this).find('.preview_window').css({'position':'absolute','left':'0px'});
},
function(){
    $(this).css({'height':'29px','width':'29px'});
    $(this).find('.preview_window').css({'position':'absolute','left':'-9999px'});
});
于 2013-05-07T15:27:28.370 回答