href inside href [duplicate]

末鹿安然 提交于 2019-12-11 01:48:06

问题


I have a clickable panel within which I have a tooltip. The code looks as follows:

<a href="/venues/manage/">
 <div class="col-md-4">
    <div class="panel panel-default">
     <img src="/img/venue.svg">
     <h5 class="text-vert crop"><b>Venue Title</b><a href="#" data-toggle="tooltip" title="Verified Venue">Verified</a></h5>
    </div>
 </div>
</a>
<script>
$(document).ready(function(){
    $('[data-toggle="tooltip"]').tooltip();
});
</script>

When I hover over the tooltip text it works fine. Something about the tooltips messes with the main link <a href="/venues/manage/">. When I click the image, the link works fine. When I click the text Venue Title it works fine. But if I click anywhere else in the <div class="col-md-4"> (such as to the right of the text) the link doesn't work.

Is it possible to have a <a> tooltip within another <a>?


回答1:


In order to have nested a please do the following changes ....

You have to wrap the nested a inside a object tag.

<a href="/venues/manage/">
 <div class="col-md-4">
    <div class="panel panel-default">
     <img src="/img/venue.svg">
     <h5 class="text-vert crop">
         <b>Venue Title</b>
         <object><a href="#" data-toggle="tooltip" title="Verified Venue">Verified</a></object>
     </h5>
    </div>
 </div>
</a>

Here is a bootply (see the generated HTML) : http://www.bootply.com/MmYwCLTF0P

Here is a conference from Vitaly Friedman : https://vimeo.com/162334949



来源:https://stackoverflow.com/questions/41959446/href-inside-href

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!