2015-02-11 23 views
0
$(document).ready(function() { 
    // get width of screen 
    var Docwidth = 0; 
    $(window).resize(function() { 
     Docwidth = $(document).width(); 

     //if width of document smaller screen 

     if (Docwidth < 768) { 
      //turn on accordion 
      $('#accordion').accordion({ 
       heightStyle: false 
      }); 
     } else { 
      // turn off function when i change screen size 
      $('#accordion').accordion("disable"); 
     } 
    }); 
}); 
+1

你能更具體的innerWindow?你想刪除哪個功能? – 2015-02-11 09:31:17

+1

你能把它變成一個真正的問題嗎? – 2015-02-11 09:31:24

+0

您是否嘗試過$('#accordion')。accordion(「destroy」)? – 2015-02-11 09:35:01

回答

0

試試這個。

$(document).ready(function() { 
// get width of screen 
var Docwidth = 0; 
    testWindowWidth(); 
}); 

$(window).resize(function() { 
    testWindowWidth(); 
}); 

function testWindowWidth(){ 
    Docwidth = $(document).width(); 

    //if width of document smaller screen 

    if (Docwidth < 768) { 
     //turn on accordion 
     $('#accordion').accordion({ 
      heightStyle: false 
     }); 

    } else { 
     // turn off function when i change screen size 

     $('#accordion').accordion("disable"); 

    } 
} 

你要設定的功能「$(窗口).resize();'$(document).ready();「 - 功能,因爲在」就緒「中它將只運行一個。

希望我能幫上忙。

Demo < - 你必須改變紅塊:)

+0

非常感謝你 – 2015-03-02 09:54:59

+0

您的歡迎:) – Fr0zenOfficial 2015-03-03 15:11:05