I would like to show something only if the window size is bigger than 1000px
. It should work on load, and if the window size changes.
This is my try:
$(window).on("resize", function() {
if ($(window).width() > 1000) {
alert("Hello!");
});
}
}).resize();
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
Unfortunately, it doesn't work like expected. What should be changed?