Svetoslav
Svetoslav

Reputation: 4686

Remove href from inner div tag?

I use one jquery for showing tips. It creates DIV tag inside A tag. For example...

<a href="mypage.html">Title</a>

On hover becomes..

<a href="mypage.html">Title <div class="tooltip">My text....</div></a>

Its working great. But the "My text...." is clickable link (because its inside the A>HREF). Is there any way to make it not clickable without moving it out from the A tag?

Upvotes: 0

Views: 382

Answers (2)

Nicola Peluchetti
Nicola Peluchetti

Reputation: 76880

You could attach an handler to your and then check the target that generated the event, if it is the div, just return false

$('a').click(function(e){
   if($(e.target).hasClass('tooltip')){
      return false;
   }
});

fiddle here http://jsfiddle.net/FfVWv/

Upvotes: 2

Guffa
Guffa

Reputation: 700362

No, there isn't.

You should not put a div tag inside an anchor tag anyway, as that blows up in browsers that doesn't support HTML 5.

Upvotes: 0

Related Questions