var $window = jQuery(window); function checkWidth() { var windowsize = $window.width(); if (windowsize > 1400) { jQuery("#first-tab").click(function() { //do something }); } else { jQuery("#first-tab").click(function() { //do something }); } } // Execute on load checkWidth(); // Bind event listener jQuery(window).bind('resize', checkWidth);