简体   繁体   中英

Linkbutton click event not firing via JQUERY

I have a link button on page which is rendered like this in html

<a id="lb_download" href="javascript:__dopostback...">download</a>

I am trying to trigger the click event of that button using JQUERY

$('#lb_download').click();

But its not firing. Direct clicking is working fine with the button. but using JQUERY is not

What I did wrong

Adding little more details I tried a jquery event handler for the click event if firing or not

$('#lb_download').click(function(){
alert(10);
});

The weird part is its working and the alert is showing, but the post back or server side travel is not happening.. which happens when we click directly..

由于使用jquery的click()方法时不会发生服务器端调用,因此无法使用eval解决如下问题。

eval($('#lb_download').attr('href'));

try this it worked in my case

document.getElementById('lb_download').click();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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