I have a tabbed content box that when a tab is clicked, a '#div1' is appended to the end of my URL. Is there a way of preventing jQuery from doing this?
I still can't get it to work. I've made a fiddle...
/
I have a tabbed content box that when a tab is clicked, a '#div1' is appended to the end of my URL. Is there a way of preventing jQuery from doing this?
I still can't get it to work. I've made a fiddle...
http://jsfiddle/k6Ks8/
Share Improve this question edited Jan 27, 2012 at 14:53 Lightness Races in Orbit 385k77 gold badges665 silver badges1.1k bronze badges asked Jan 27, 2012 at 14:16 LiamLiam 9,85540 gold badges114 silver badges214 bronze badges 1- Please take more care over your posts. Punctuation matters. – Lightness Races in Orbit Commented Jan 27, 2012 at 14:53
2 Answers
Reset to default 13Sure, event.preventDefault()
is what you are looking for.
http://api.jquery./event.preventDefault/
easy
$(function(){
$('a[href="#"]').click(function(event){
event.preventDefault();
});
});