jQuery重写事件 [英] jquery override event

查看:190
本文介绍了jQuery重写事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样的主播

<a href='#' onclick='return showform(this)'>click me</a>

但是我希望能够覆盖onclick函数,如何在jquery中做到这一点?

But I want to be able to override the onclick function, how to do this in jquery?

因为好像我添加了

$('a').click( function() { alert('hi there!'); } );

新的点击处理程序不会取代旧的点击处理程序

the new click handler is not overriding the old one

推荐答案

您是否尝试过以下方法:

Have you tried something like this:

$("a").removeAttr("onclick");

这篇关于jQuery重写事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆