I've got a pretty basic jquery function that accepts two arguments, maxWidth and minWidth. The arguments check the users browser size and performs an action based upon their browser size.
$.fn.browserWidth = function(maxWidth, minWidth) {
maxWidth = maxWidth || 1100;
return document.documentElement.clientWidth >= maxWidth;
return document.documentElement.clientWidth <= minWidth;
};
})(jQuery);
The first conditional works at a normal browser size:
if(browserWidth(1099)){ //do something }
However the second conditional always fires but I only want it to fire at the mobile breakpoint
if(browserWidth(0,1099)){ //do something }
Am I wrong in setting the first argument to zero? Ideally I don't even want the first argument and just want to check the minWidth in this situation. But there are other instances when I just want to check the maxWidth? Any ideas? Thanks!
returnwill never be reached as you have already returned something above. I think you want:return document.documentElement.clientWidth >= maxWidth && document.documentElement.clientWidth <= minWidth;