[英]How to make an anchor with a div inside with a different link
I'm trying to make a card that is all clickable (the class=box) Except for one section that contains buttons which each links to different links that its parent anchor.. 我正在尝试制作一张全部可点击的卡片(class = box),除了一个包含按钮的部分,每个按钮都链接到其父锚点的不同链接。
I don't find a way to have one link for the card and a different for a section inside. 我找不到一种方法来为卡设置一个链接,而为其中的一部分设置一个链接。
<a class="box" href="box-link.html">
<div class="box-text">
<span>Some Text here</span>
<div style="float:right; " ng-click="dosomeotherstuff()">
<span class="glyphicon glyphicon-trash"></span>
</div>
<div style="float:right; " ng-click="somethignelse()">
<span class="glyphicon glyphicon-share"></span>
</div>
</div>
</a>
I'm using Angular, hence the ng-clicks. 我正在使用Angular,因此使用ng-clicks。
Any ideas on how to sort this out? 关于如何解决这个问题的任何想法?
Adding a fiddle example: http://jsfiddle.net/pepepapa82/svwLh6w1/ 添加小提琴示例: http : //jsfiddle.net/pepepapa82/svwLh6w1/
You can add more than one action to an ng-click
. 您可以向
ng-click
添加多个动作。 In this case, you might want to first prevent the click
event propogating, then trigger your sub-action: 在这种情况下,您可能要先阻止
click
事件传播,然后触发子操作:
<a class="box" href="box-link.html">
<div class="box-text">
<span>Some Text here</span>
<div style="float:right; " ng-click="$event.stopPropagation(); dosomeotherstuff()">
<span class="glyphicon glyphicon-trash"></span>
</div>
<div style="float:right; " ng-click="$event.stopPropagation(); somethignelse()">
<span class="glyphicon glyphicon-share"></span>
</div>
</div>
</a>
As an alternative, you could pass $event
as the first argument of your functions, and stop propogation there. 或者,您可以将
$event
作为函数的第一个参数传递,并在此处停止传播。 This is, IMHO, cleaner . 恕我直言,这是更清洁的 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.