[英]Prevent anchor link from being added to URL
I have a tabbed content box that when a tab is clicked, a '#div1' is appended to the end of my URL. 我有一个标签式内容框,当单击选项卡时,“#div1”会附加到我的URL末尾。 Is there a way of preventing jQuery from doing this?
有没有办法阻止jQuery这样做?
I still can't get it to work. 我仍然无法让它发挥作用。 I've made a fiddle...
我做了一个小提琴......
Sure, event.preventDefault()
is what you are looking for. 当然,
event.preventDefault()
就是你要找的。
http://api.jquery.com/event.preventDefault/ http://api.jquery.com/event.preventDefault/
easy 简单
$(function(){
$('a[href="#"]').click(function(event){
event.preventDefault();
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.