When $(window).width() == 768
, an alert()
is executed. But in Chrome DevTools
this actually happens when width is 786px. Why and how to make my JS fire at 768px not 786?
Have you tried simply:
window.innerWidth
or for backwards-compatibility with older browers
window.innerWidth
|| document.documentElement.clientWidth
|| document.body.clientWidth