2012-05-21 70 views
0

我有选择的鼠标悬停我的选项卡这两个功能褪色,第一个是左边:jQuery的鼠标悬停在功能

$(function() { 
     var $items = $('#vtab>ul>li' || '#vtab2>ul>li'); 
     $items.mouseover(function() { 
      $items.removeClass('selected'); 
      $(this).addClass('selected'); 

      var index = $items.index($(this)); 
      $('#vtab>div' && '#vtab2>div').hide().eq(index).show(); 
     }).eq(0).mouseover(); 
    }); 

这一个对右侧:

$(function() { 
     var $items = $('#vtab2>ul>li'); 
     $items.mouseover(function() { 
      $items.removeClass('selected'); 
      $(this).addClass('selected'); 

      var index = $items.index($(this)); 
      $('#vtab2>div').hide().eq(index).show(); 
     }).eq(0).mouseover(); 
    }); 

,然后我有变淡的页面和退出的另一个功能:

$(文件)。就绪(函数(){$ ( “身体”)的CSS( “显示”, “无”);

$("body").fadeIn(3000); 

$("a.transition").click(function(event){ 
    event.preventDefault(); 
    linkLocation = this.href; 
    $("body").fadeOut(2000, redirectPage); 
}); 

function redirectPage() { 
    window.location = linkLocation; 
} 

});

由于某些原因,第二个函数只在页面淡入时起作用,一旦动画完成,它就停止工作。第二个功能也适用,如果我使屏幕足够小,我不能同时看到我的两个垂直列表。

有谁知道这可能是为什么?我是jQuery的新手,我真的不知道从哪里开始。

回答

0

我相信你的问题是错误地使用JavaScript的布尔运算符。 $('#vtab> ul> li'||'#vtab2> ul> li');

相当于: $( '#vtab> ul>礼')

由于 '#vtab> ul>李' 是真实的, “||” 广义布尔是JavaScript的“或”运算符和“或”短路的第一个真正的发现。

一些相关的事实:

true || true || true == true 
false || true || false == false 
false || 'hey there' || true == 'hey there' 
'hey there' || true == 'hey there' 
'hey there' && true == true 
true && 'hey there' == 'hey there' 
+0

的“或”部分是不必要的,但我仍然有相同的问题了。我最大的困惑来自这样的事实,即当我无法同时看到两个列表时,两者都可以很好地工作 –