javascript - JQuery trigger() not working -


  $(function(){        $('.parent-class h3').click(function(){           $(this).siblings('p').find('a').trigger( "click" );           //var h = $(this).siblings('p').find('a').attr( "href" );           //alert(h);        });    });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>    <div class="parent-class">      <p class="child-class">          <a href="hello.jpg" data-rel="lightbox-1">lightbox image</a>      </p>      <h3>title here</h3>  </div>

i have used lightbox in website. want show lightbox while click on h3 tag. have alert a href(commented line) working fine. not working trigger. please see above code. , tell me why trigger('click') not working in code.

thank you

edit - forgot lightbox. simple anchor link not working.

change javascript code this:

$(function(){       $('.parent-class h3').click(function(){          $(this).siblings('p').find('a')[0].click();       }); }); 

jquery trigger won't work because no click event binded element, javascript click function, simulate actual click 1 mouse!


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -