// Responsive JavaScript
$(function() {
function showSidebar() {
$('#outer').stop().animate({width:"80%"}, 400, function() {
$('#main', this).stop().animate({width:"60%"}, 400, function() {
$(this).next().slideDown('slow');
});
});
}
// When the window is resized, execute the if-else function
$(window).resize(function() {
var winWidth = $(window).width(); // Get the window width
// If the window size is smaller than 400...
if(winWidth < 400) {
// Do the animation bellow
$('#sidebar').slideUp('slow', function() {
$(this).prev().stop().animate({width:"100%"}, 400, function() {
$(this).parent().stop().animate({width:"100%"}, 400);
});
});
} else {
// If the window size is greater than 400, run the showSidebar() function!
showSidebar();
}
});
});
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.