This code should print:
- if the screen width is < 740 or is 740.
- if the screen width is > 740 and the screen width is < 1065
- if the screen width is >1065 or is 1065
- if the screen width is >1389 or is 1389
But it always shows 2 or 3 randomly when the 4th condition is true.
whats the problem in here? Take a look at the console.
https://codepen.io/code_alex/pen/xJLwpq
var screenWidth = $(window).width();
if(screenWidth < 740 || screenWidth == 740) {
console.log("1");
} else if(screenWidth > 740 && screenWidth < 1065){
console.log("2");
} else if(screenWidth > 1065 || screenWidth == 1065) {
console.log("3");
} else if (screenWidth > 1389 || screenWidth == 1389) {
console.log("4");
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
Aucun commentaire:
Enregistrer un commentaire