按钮onclick整个可点击的div内 [英] Button onclick inside whole clickable div
本文介绍了按钮onclick整个可点击的div内的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个可点击的整个div。
这是我的代码:
I have a whole clickable div. This is my code:
<div onclick="location.href='@Url.Action("SubClass", "Product", new { id = productClass.HierarchyId })';" class="menu-class">
<img src="~/Images/ClassImages/@imageName" alt="@productClass.HierarchyShort" />
<div class="menu-class-text">
<span>@productClass.HierarchyShort</span>
</div>
<div class="menu-class-admin-options">
<button onclick=" location.href = '@Url.Action("EditClass", "Product")'; ">Edit</button><br/>
<button onclick=" location.href = '@Url.Action("DeleteClass", "Product")'; ">Delete</button>
</div>
</div>
这是一个带有产品和组名称图像的div。当用户将其悬停在div show 2按钮的编辑和删除中时。
问题是当我点击Div内的任何按钮时,它调用div的onclick,而不是按钮的onclick。
请帮忙吗?
对不起我的英语。
This is a div with image of product and group name. And when user hover it, inside the div show 2 buttons Edit and Delete. The problem is when I click on any button inside Div, its call the div's onclick, not the button's onclick. PLease any help? Sorry my english.
推荐答案
谢谢大家。就像robooneus。
我只是把这个:
Thanks for all. As say robooneus. I just put this:
<button onclick=" location.href = '@Url.Action("NewClass", "Product")'; event.stopPropagation(); ">Edit</button><br/>
现在正在工作。谢谢你。
And now is working. Thanks all.
这篇关于按钮onclick整个可点击的div内的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文