我正在尝试使其正常工作,但 && 不起作用。我试图让底部按钮在滚动时显示,但对于其他所有内容都不显示,除非 .yes == 不显示。
有人可以帮忙吗?
另外,如何压缩下面这 3 个脚本的代码?
<script>
$(window).load(function(){
if($('.yes').css('display') == 'none')
{
$('#button').css('display', 'block');
}
});
</script>
<script>
$(document).scroll(function () {
var y = $(this).scrollTop();
if (y > 300) {
$('#bottombadge').fadeIn();
$('.bottomcta').fadeIn();
$('.bottomandroid').fadeIn();
$('.bottomapple').fadeIn();
/*$('#bottombutton').fadeIn();*/
} else {
$('#bottombadge').fadeOut();
$('.bottomcta').fadeOut();
$('.bottomandroid').fadeOut();
$('.bottomapple').fadeOut();
/*$('#bottombutton').fadeOut();*/
}
});
</script>
<script>
$(document).scroll(function () {
var y = $(this).scrollTop();
**if (y > 300) && ($('.yes').css('display') == 'none'){**
$('#bottombutton').fadeIn();
} else {
$('#bottombutton').fadeOut();
}
});
</script>
非常感谢对此的任何帮助。再次感谢
最佳答案
您有语法错误
这个:
if (y > 300) && ($('.yes').css('display') == 'none')
应该是这样的:
if ((y > 300) && ($('.yes').css('display') == 'none'))
关于javascript - && 滚动上出现意外标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42632856/