What I want is that: There is a link on top of page. When it is clicked, it should go to in the same page and toggle a div class with jquery.But both of are not working at the same time.. For example:为什么<a href=#A> and jquery click function not work together?
<a href='#A' id='link'>Go to A and toggle a div class</a>
jquery codes are:
$('#link').click(function() {
$('.toggle').toggle();
});
<a name='A'> Here is A </a>
my codes are more complex than that but same logic with I write here. When I click the link, the div which has toggle class toggles. First it looks jquery codes. But it does not go to #A. That is to say, href attribute is not working. Any idea?...
怎么样在jsfiddle.net – Dhiraj
一个小样本提供一个[的jsfiddle(http://jsfiddle.net)例子吧。 – iambriansreed
这应该工作得很好。现场示例 - http://jsfiddle.net/v8Z53/。 –