[英]Javascript and jquery stop event
I have a small issue: 我有一个小问题:
I have a jquery onclick event set for a row() in a table and in the last column I have a link that opens a confirmation pop-up(asking if I am sure to do that bla bla . . .). 我有一个jquery onclick事件设置为一个表中的row(),在最后一列我有一个链接打开一个确认弹出窗口(询问我是否确实这样做bla bla ...)。 If I click the link, the pop-up opens, and if I press no, it should stay on the current page, but instead it continues with the event from the row(that click is triggered). 如果我单击该链接,弹出窗口将打开,如果我按否,它将保留在当前页面上,而是继续该行中的事件(触发该点击)。 What do you think? 你怎么看?
Link: 链接:
<tr class="clickableRow" id="someId"> bgcolor="color">
..........
<td>
<a href="javascript:void(0)" onClick="javascript:del_prompt('url');"> <img src="images/delete.png" border="0"></a>
</td>
</tr>
Javascript: 使用Javascript:
$(".clickableRow").click(function() {
window.open("companynewestimate.php?id="+this.id,"_parent");
});
Del function Del功能
<script language="javascript">
function del_prompt(id)
{
if(confirm ("Are you sure you want to delete selected Record")){
location.href = "companyopenestimates.php?act=del&id="+id;
}
else{
return false;
}
}
</script>
Without some code, it's hard to get the correct answer. 没有一些代码,很难得到正确的答案。 But maybe this helps: 但也许这会有所帮助:
$("#element").on("click",function(e){
//do something
e.preventDefault();
e.stopPropagation();
})
See here: http://api.jquery.com/event.stopPropagation/ 见这里: http : //api.jquery.com/event.stopPropagation/
Changing your link's onclick
should do the trick: 更改链接的onclick
应该可以解决问题:
onClick="del_prompt('<?=$line['id_est']?>'); return false;"
Note that the javascript:
is not at all needed. 请注意, javascript:
根本不需要。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.