href inside href [duplicate]

2019-07-15 08:33发布

This question already has an answer here:

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条回答
戒情不戒烟
2楼-- · 2019-07-15 08:54

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

查看更多
登录 后发表回答