0
如何优化下面的jquery?我知道我们可以结合2条件,但不确定确切的语法。jQuery优化 - 结合两个条件?
$(window).scroll(function() {
if ($('sbar-bottom-w').isOnScreen() != false || $('sbar-top-w').isOnScreen()!=false) {
if($('sbar-top-w').offset().top-$(window).scrollTop()<45){
$('#article-share').show();
}else{
$('#article-share').hide();
}
} else {
$('#article-share').show();
}
这是绝对正确的,但你不觉得它以前的方式是更好的吗?我的意思是我从来没有使用这种方式结合两个if语句 – 2014-10-09 17:42:54
@AminJafari现在TS有东西比较,并决定什么更好)) – Cheery 2014-10-09 17:44:03
谢谢,它的工作原理。 – tv4free 2014-10-09 18:35:29