Give this a try.
$(document).ready(function () {
// check screen width
var Docwidth = 0;
testWindowWidth();
});
$(window).resize(function () {
testWindowWidth();
});
function testWindowWidth(){
Docwidth = $(document).width();
//if document width is smaller than screen
if (Docwidth < 768) {
//activate accordion
$('#accordion').accordion({
heightStyle: false
});
} else {
// deactivate function when screen size changes
$('#accordion').accordion("disable");
}
}
You should place the '$(window).resize();' outside of the "$(document).ready();" section, as it will only run once within "ready".
I hope this information was useful.
Check out the Demo <- Don't forget to modify the innerWindow of the red block :)