DIV单击时滚动到顶部? [英] Scroll To Top When DIV Clicked?

查看:94
本文介绍了DIV单击时滚动到顶部?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们都知道,通过HTML滚动到顶部与命名的锚点是可能的...但是,是否可以滚动到顶部,当另一个HTML元素被点击,不被A标签回收?例如,像一个DIV?

We all know that Scroll to Top with Named Anchors via HTML is possible... But, is it possible to scroll to the top when another HTML element is clicked that is not sorrounded by A tags? For instance, like a DIV?

谢谢!

所有,我没有看到这是一个重复的问题。我做了一个搜索,没有找到任何开始。

Apologies all, I did not see this was a duplicate question. I did a search and didn't find anything to begin with.

推荐答案

$('div').on("click",function(){
      $(window).scrollTop(0);
});

您可以将每种html标签插入括号

You can insert every kind of html tag into the bracket's

这篇关于DIV单击时滚动到顶部?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆