Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
if($('html, body').scrollTop().val() > 50){ $("#scrolltop").css("display", "block"); };
这些是我的代码,但当然不起作用。我如何通过“如果”提问来申请它..?
我不太清楚你的意思。
您是否有一个元素“scrolltop”,如果主体滚动超过 50 像素,您只想显示该元素?
如果是这样,这里是一个例子:http: //jsfiddle.net/t52HN/4/