[英]make div disappear 850px from bottom only when screen is less than 600px wide
I have this function that makes my div disappear 850 px from the bottom of the page我有这个功能可以让我的 div 从页面底部消失 850 px
<script type="text/javascript">
$(window).scroll(function() {
if($(window).scrollTop() + $(window).height() > $(document).height() - 850) {
$('.guide').hide();
}
else {
$('.guide').show();
}
});
</script>
but i'd like this to ONLY happen if the screen is 600px wide or less, how can i do this?但我希望只有在屏幕宽度为 600 像素或更小时才会发生这种情况,我该怎么做?
You can use $(window).width()
:您可以使用
$(window).width()
:
<script type="text/javascript">
$(window).scroll(function() {
if($(window).scrollTop() + $(window).height() > $(document).height() - 850 && $(window).width() <= 600) {
$('.guide').hide();
}
else {
$('.guide').show();
}
});
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.