
那应该起作用,您能否阐明“之前”的含义?你在做这个吗?
jQuery("#id_of_anchor").click(function(event) { event.preventDefault(); Function_that_does_ajax();});因为从某种意义上来说这 应该 起作用,如果它不起作用,则说明您做错了什么,我们需要查看更多代码。但是,为了完整起见,您还可以尝试以下 *** 作:
jQuery("#id_of_anchor").click(function() { Function_that_does_ajax(); return false;});编辑
这是此工作的示例。
这两个链接使用以下代码:
$('#test').click(function(event) { event.preventDefault(); $(this).html('and I didnt scroll to the top!');});$('#test2').click(function(event) { $(this).html('and I didnt scroll to the top!'); return false;});如您所见,它们工作正常。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)