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.
$("#list").slideDown("slow"); //code to slide down the div dag when it is clicked.
它工作正常,但是当我点击标签时,浏览器突然向上滚动到顶部。
所以我必须向下滚动到标签才能看到它的内容。
请帮我。
谢谢,
拉吉
在您的点击处理程序中,您需要return false或使用event.preventDefault();. 一个示例点击处理程序将是:
return false
event.preventDefault();
$("#element").click(function(event){ $("#list").slideDown("slow"); return false; });
没有看到更多的 HTML 代码是不可能确定的,但是当你有类似<a href='#' onclick='.....'>. 告诉浏览器#转到页面顶部。
<a href='#' onclick='.....'>
#