2012-01-04 81 views
0

所以我得到这个jQuery插件为主动滑动菜单标签:激活(或没有)jQuery插件,根据屏幕宽度

$(document).ready(function() { 
var closeAll, 
    $parentItem = $('div#tabWrapper'), 
    slideAmt = $('div#tabBG').width(), 
    direction; 

$('a#toggle').click(function() { 
     if (parseInt($parentItem.css('marginLeft'), 10) < 0) { 
      direction = '+='; 
      $(this).addClass('expanded'); 
     } 
     else { 
      $(this).removeClass('expanded'); 
      direction = '-='; 
     } 
    $parentItem.animate({marginLeft: direction + slideAmt}, 400) 
    return false; 
}); 

$parentItem.mouseleave(function() { 
    closeAll = setTimeout(function() { 
     $('a#toggle').removeClass('expanded').parent().animate({marginLeft: -slideAmt}, 300); 
     return false; 
    }, 600); 
}) 
.mouseenter(function() { 
clearTimeout(closeAll); 
}) }); 

但我只希望这个动画上比1,024像素更高的屏幕宽度工作。

这会如何发生?

谢谢大家!

回答

0

你可以使用

screen.height; 
screen.width; 

然后你要根据这些数值

+0

对不起,我真的在jQuery的一个小白做什么屏幕分辨率。我试着在代码的开头添加'if(screen.width> = 1024)',但没有成功...... – PMaly 2012-01-04 15:15:10

+0

'if(screen.width> = 1024){// code to run};'should work。很简单的例子:http://jsfiddle.net/k55fU/ – ManseUK 2012-01-04 15:56:02

+0

仍然没有工作。 Arrggg!无论如何感谢您的帮助。 – PMaly 2012-01-04 18:05:51