This code is working properly when I remove the if() {}
but I want the css style to work just for specific window widths. When I add the if
statement it doesn't read the CSS style anymore. Any idea why?
$(document).ready(function() { $(".icon").mousemove(function() { $(this).hide(); $(".second").show(2000); if (windows.innerWidth > 768) { $(".second").css({ "display": "grid", "grid-template": "200px / 200px 200px" }); } }); }); I also tried this and still not working: $(document).ready(function(){ $(".icon").mousemove(function() { $(this).hide(); $(".second").show(2000); if ($(window).width() > 768){ $(".second").css({ "display": "grid", "grid-template": "200px / 200px 200px" }); } else { $(".second").css({ "display": "grid", "grid-template": "100px / 100px 100px" }); } }); });
https://stackoverflow.com/questions/65785218/changing-css-with-jquery-in-different-screen-size January 19, 2021 at 11:47AM
没有评论:
发表评论