There is a div block, a link is embedded in it. There is a function hanging on the block, which returns return false by clicking on this block.

How to make the link inside work by default, that is, the transition is made on this link.

In this case, clicking the link blocks the function that hangs as a handler on the div.

$('.wrap').click(function(e) { return false; }) 
 .wrap { width: 300px; height: 300px; border: 1px solid red; } 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="wrap"> <a href="https://www.google.ru/" target="_blank">fwfwefwefwef</a> </div> 

    1 answer 1

    Option 1. Remove the return false from the div, why is it here? :)

    Option 2. Catch the message in the child and cancel its distribution to the top:

     $('.wrap').on('click', 'a', function (e) { e.stopPropagation(); }); 
    • None of the options fit - ruslik
    • 2
      @ruslik and why? No one can help you if you do not tell about their difficulties. - Pavel Mayorov
    • @ruslik, here's a head-on option, but I won't even make out the answer: $('.wrap a').click(function(){ location.href = this.href; }); - Deonis
    • @Deonis you forgot about the target :) - Pavel Mayorov
    • @PavelMayorov, but will there always be a? - Grundy