我正在阅读jQuery的animate()页面
http://api.jquery.com/animate/
它的示例没有提及是否使用
@H_404_10@<a href="#" id="clickme">click me</a> ... $('#clickme').click(function() { $('#someDiv').animate({left: "+=60"}); })
我们实际上仍然必须像过去一样返回false?
@H_404_10@$('#clickme').click(function() { $('#someDiv').animate({left: "+=60"}); return false; })
(但随后,这些示例并未将< a>用于“点击我” …而是使用了其他内容.
最佳答案
您需要使用event.preventDefault():
@H_404_10@$('...').click(function(event) { event.preventDefault(); // Code. });
event.preventDefault()
Description:
If this method is called,the default
action of the event will not be
triggered.