I have the following jQuery script. It handles the display of a responsive menu (toggle the menu display when in mobile screens), but also restores the display of the menu, in desktop browsers after restoring the size of the browser window. The script works with no issues. I am wondering if there is room for improvement... What would be the efficient approach to this, so the script will not have to run unneeded functions when in screen sizes bigger than 768px.
jQuery(document).ready(function($) {
$('.menu-toggle').click(function() {
$('.navmenu').slideToggle('fast');
});
$('.menu-toggle a').click(function(e) {
e.preventDefault();
});
$(window).resize( function() {
var w = $(window).width();
if (w > 768) {
$('.navmenu').css('display','')
}
});
});