简体   繁体   English

与onclick和_dopostback和jquery click事件链接

[英]link with onclick and _dopostback and jquery click event

I have a link (a tag) which is given an onclick event and has dopostback enabled, when generated server-side. 我有一个链接(标签),当生成服务器端时,该链接被赋予onclick事件并启用了dopostback。 To this link, I later bind a jquery click event. 对此链接,我以后绑定一个jquery click事件。

The onclick event has return false; onclick事件已return false; at the end of the function and the anonymouse function binded by jquery has return true; 在该函数的末尾,并且由jquery绑定的匿名函数已return true;

When I click on the link the jquery function is run and the postback happens, but the code in the inline onclick event is not working. 当我单击链接时,将运行jquery函数并发生回发,但是内联onclick事件中的代码不起作用。

I tried flipping around the return false and return true. 我试图翻转返回false并返回true。

When the jquery function returns false, the code works in Chrome and FF, but not IE. 当jquery函数返回false时,代码可在Chrome和FF中运行,但不适用于IE。

When the jquery function returns true, the code works in IE, but not in FF or Chrome. 当jquery函数返回true时,代码将在IE中工作,但不能在FF或Chrome中工作。

I have also tried adding the inline code to the onmouseup event, but that does not help either. 我也曾尝试将内联代码添加到onmouseup事件中,但这无济于事。

Maybe I am missing something but why would one ever have jQuery do one thing with a bound event then have an onclick event on the element do another. 也许我错过了一些东西,但是为什么有人要让jQuery对绑定事件做一件事,然后对元素进行onclick事件呢?

Just use jQuery to 2 both and don't forget to use e.preventDefault() as the first line of the function. 只需将jQuery都使用2,别忘了使用e.preventDefault()作为函数的第一行。

Post the relevant code and I will try to assist further. 发布相关代码,我将尽力提供进一步的帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM