0
我正在嘗試使響應web,但我有調整寡婦寬度的麻煩。 當窗口寬度小於885時,第一個代碼如果工作正常,但是當窗口寬度大於885時,它有一個問題,,,,即使我阻止點擊事件(關閉),當我嘗試調整大小再次,在控制檯仍然有「無」和「塊」也點擊事件發生和'.common-a'被點擊有{不透明度:0;}。Jquery窗口調整大小和點擊事件
下面是我的代碼。
var $window=$(window);
function intoTablet(){
var width=$window.width();
if(width<=885){
$('#wrapping .hidden-gnb .common-ul >li').on('click',function(ee){
$(this).siblings().children('.hover-ul-inner').css('display','none');
$(this).siblings().children('.common-a').css({'opacity':1});
console.log("none");
$(this).children('.hover-ul-inner').css('display','table');
$(this).children('.common-a').css({'opacity':0});
console.log("block");
});
}
if(width>885){
$('#wrapping .hidden-gnb .common-ul >li').off('click',function(ee){
$(this).siblings().children('.hover-ul-inner').css('display','none');
$(this).siblings().children('.common-a').css({'opacity':1});
console.log("none");
$(this).children('.hover-ul-inner').css('display','table');
$(this).children('.common-a').css({'opacity':0});
console.log("block");
});
}
}
intoTablet();
$window.on('resize',function(){
intoTablet();
console.log("resizing");
});
感謝它的工作原理幾乎!!沒有更多的console.log(「block」)和console.log(「none」)。但是當窗口變大時,'.common-a'仍然具有不透明度:0;價值。我怎麼能解決這個問題? – 2014-10-30 15:35:56
@JoJay的作品差不多?什麼不行? – 2014-10-30 15:36:26
我想在這裏顯示快照嗎? – 2014-10-30 15:38:44