我想測試如果IE是版本7或8,並且它是否阻止特定的代碼段運行?如何測試Internet Explorer版本是否爲版本7或版本8?
我嘗試下面的代碼,但這似乎沒有工作:
if($.browser.msie && parseInt($.browser.version, 10) <= 8) {
$(document).on('mouseenter', '.thumb', function() {
$(this).find('.bgg').stop().animate({ opacity : 1 });
});
$(document).on('mouseleave', '.thumb', function() {
$(this).find('.bg').stop().animate({ opacity : .5 });
});
}
理想我真的不想使用這種檢測,但在這種情況下,必須使用。
全局是醜陋 – Christoph 2012-04-05 12:21:21
我有一個全球唯一的另一件事是,我運行整個腳本我的對象字面命名空間。我不濫用它,因此保持清潔。 – 2012-04-05 12:24:00
爲什麼不把它包含在你的名字空間呢?全局變量容易發生不必要的修改。 UA嗅探極易出錯。 – Christoph 2012-04-05 12:27:27