admin管理员组文章数量:1393416
Think this is a quickie for someone. I have this markup (generated by ASP.Net)...
<A id=anchorO href="javascript:__doPostBack('anchorO','')">O</A>
This anchor is in an update panel, and if I click it manually a partial postback takes place. However....
$('[ID$="anchor'+initial+'"]').click() //JavaScript
..selects the correct anchor, but no postback takes place. Why is this?
Think this is a quickie for someone. I have this markup (generated by ASP.Net)...
<A id=anchorO href="javascript:__doPostBack('anchorO','')">O</A>
This anchor is in an update panel, and if I click it manually a partial postback takes place. However....
$('[ID$="anchor'+initial+'"]').click() //JavaScript
..selects the correct anchor, but no postback takes place. Why is this?
Share Improve this question asked Apr 15, 2011 at 10:24 El RonnocoEl Ronnoco 11.9k5 gold badges40 silver badges67 bronze badges 1- stackoverflow./a/26560976/184572 – Iman Commented Oct 25, 2014 at 9:25
2 Answers
Reset to default 6A click and a href are seen as two different things in Javascript, so you can't do .click()
and call the href, regardless if this is calling javascript:
or not
Two options:
Just do:
$('#anchor' + initial).click(function() { __doPostBack('anchorO',''); });
Be evil and use eval:
$('#anchor' + initial).click(function() { eval($(this).attr('href')); });
See this question here
It appears that you can't follow the href of an a tag using the click event.
本文标签: javascriptWhy does jQuery click() not cause postback when used on this ltagt tagStack Overflow
版权声明:本文标题:javascript - Why does jQuery .click() not cause postback when used on this <a> tag? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744754132a2623357.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论