You can bind window resizing events by doing the following:
$(window).on('resize', function(event){
});
You can get the window size by following these steps:
var windowWidth = $(window).width();
if(windowWidth < 640){
}
So your function will work as follows:
$(window).on('resize', function(event)
{
var windowWidth = $(window).width();
if(windowWidth < 640){
$('p').css('display','none');
$('h1').click(function(){
$('p').stop(true,true).slideToggle(1000);
});
}
});
source
share