2012-01-04 78 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