javascript - a链接标签嵌套span链接标签,如何单独触发一个链接?
本文介绍了javascript - a链接标签嵌套span链接标签,如何单独触发一个链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
如图,整个白色框为a标签, Read more为span标签。现在点击span标签会同时触发a标签,该如何解决?
<li>
<a href="http://www.behance.net" target="_blank">
<div class="web-content">
<div class="web-content-top">
<div class="web-logo">
<img class="img-responsive" src="images/Behance.png" />
</div>
<span class="web-name">Behance</span>
</div>
<div class="web-content-bottom">
<div class="dot web-content-bottom-content">Behance是2006年创立的著名设计社区
<span onclick="location.href='readmore.html'" class="readmore">Read More »</span>
</div>
</div>
</div>
</a>
</li>
解决方案
$(function() {
$(".readmore").click(function(event) {
event.stopPropagation();
event.preventDefault();
window.location.href= "loding.html";
});
});
解决方案
这篇关于javascript - a链接标签嵌套span链接标签,如何单独触发一个链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文