html - jQuery link works when click on parent parent div -


i have div (a), , inside div(b), , have link. happen when click on a, link inside div(b) works.

i succeeded 1 parent, not 2...

  $(".block").mouseover(function() {      if ($(".block .button").length) {        $(this).css("cursor", "pointer").find(".invisible.button").css("text-decoration", "none");      }    }).mouseout(function(e) {      e.preventdefault();      e.stoppropagation();      $(this).find(".invisible.button").css("text-decoration", "none");    }).click(function(e) {      document.location.href = $(this).find(".invisible.button").attr("href");    });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>  <div class="wrap">    <div class="wrap-in block">      <p>content</p>      <a class="invisible button" href="mylink"> go</a>    </div>  </div>

i can't find way link work when clicking on ".wrap" div, if :)

one more information: if "wrap" has no link, have 1 more class :

the point if :

  $(".wrap").mouseover(function() {     if ($(".block .button").length) {       $(this).css("cursor", "pointer").find(".invisible.button").css("text-decoration", "none");     }   }).mouseout(function(e) {     e.preventdefault();     e.stoppropagation();     $(this).find(".invisible.button").css("text-decoration", "none");   }).click(function(e) {     document.location.href = $(this).find(".invisible.button").attr("href");   }); 

it works, works on div without anylink too...

and code stop "nolink"

$('.nolink').on('click', function(e){         e.preventdefault();         e.stopimmediatepropagation();     }); 

are looking such this:

$(".wrap").on("click", function() {     window.location = $(this).children("div.wrap-in").children("a.invisible").attr("href"); }); 

Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -