Created
August 16, 2016 15:44
-
-
Save BryanBarrera/45871fade19ec2c2f7082baecd9b369f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $(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