Force a click on a tag a with Jquery

Asked

Viewed 925 times

0

I want when mine <li> be clicked, it activates a click on the tag <a> that’s inside of him.

<li class="tab card-panel z-depth-1 ativado historia hoverable">
                <a href="#historia" class="active a">
                  <div class="row valign-wrapper">
                    <div class="col s2">
                      <i class="zmdi zmdi-assignment zmdi-hc-2x"></i>
                    </div>
                    <div class="col s10">
                      <span class="">
                        <b>SOBRE NÓS</b>
                      </span> <br>
                      <span class="">
                        Lore inpsulum dolor fech assoc
                      </span>
                    </div>
                  </div>
                </a>
              </li>

How can I do this with Jquery ?

  • what do you mean by activating a click? that the link action is executed?

  • Yes, that’s right Leo

1 answer

2


I got it guys, it was simple :

$(li).click(function{
  $("li > a")[0].click();
});

I answered my own question because someone might have the same doubt one day.

  • or you could also use $("li"). click(Function{ $("li > a"). Trigger("click"); });

Browser other questions tagged

You are not signed in. Login or sign up in order to post.