Skip to content

Instantly share code, notes, and snippets.

@BryanBarrera
Created August 16, 2016 15:44
Show Gist options
  • Select an option

  • Save BryanBarrera/45871fade19ec2c2f7082baecd9b369f to your computer and use it in GitHub Desktop.

Select an option

Save BryanBarrera/45871fade19ec2c2f7082baecd9b369f to your computer and use it in GitHub Desktop.
$(document).ready(function() {
// Optimalisation: Store the references outside the event handler:
var $window = $(window);
var $pane = $('#element');
function checkWidth() {
var windowsize = $window.width();
// if window is greater than 767
if (windowsize > 767) {
// code to execute here
}
}
// Execute on load
checkWidth();
// Bind event listener
$(window).resize(checkWidth);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment