Jquery Onclick priority vs Href
Jquery Onclick priority vs Href
我有一个小问题,在href vs onclick:
$("#table_head tr").click(function (e) {
/* My Function */
});
但是如果我使用"href":
<table id="table_head">
<tr>
<td><a href="http://stackoverflow.com">my link</a></td>
</tr>
</table>
我怎么能优先考虑三个点击请?
假设您的意思是在页面重定向之前尝试执行一些代码,您需要使用preventDefault()
停止正常的链接行为,处理您的逻辑,然后使用window.location.assign()
手动重定向页面。试试这个:
$("#table_head tr").click(function (e) {
e.preventDefault();
/* My Function */
if (e.target.tagName == 'A')
window.location.assign(e.target.href);
});
相关文章:
- setInteval vs setTimeout
- $(this).prop('property') vs. this.property
- 在单击href链接的同时下载文件
- 如果href包含X,请更改href
- 锚点元素的href属性自动更改
- 锚点元素不't使用svg时,请打开EDGE上的href
- 检测电话窃听,即:<a href="电话:xxx">在UIWebview上
- 如何覆盖锚点元素's href目标,并在我点击转到目标javascript时删除其他错误
- Js.erb VS按钮标记-不'不起作用.为什么?
- reactjs this.refs vs document.getElementById
- Href:当前DIV中的目标ID
- href属性内的javascript函数
- ng绑定和ng href问题.ng href未从控制器加载数据
- Angular and SEO, ngClick vs href
- Ng Click vs Href:哪个优先
- window.location.href vs window.location.replace vs window.lo
- this.href vs $(this).attr('href')
- 角-动态href - Vs控制器$window.location.href
- Jquery Onclick priority vs Href
- webkit / Chrome history.back(-1) onclick vs href