如何通过jQuery中的click事件捕获触发的元素?

I am trigerring an event in WordPress sub menus. When I Click one of the submenu, it should trigger a click event on another sub menu.

This is my current code:

<a href="#">Parent Category</a>

<ul class="sub-menu">
    <li class="menu-item-lidingo">
        <a href="#">Sub Cat 1</a>
    </li>

    <li class="menu-item-nacka">
        <a href="#">Sub Cat 2</a>
    </li>
</ul>

  j('.menu-item-lidingo').click(function(e) {
    console.log(j(this).attr('class'));

    j('.woof_term_224 > label').click(function(e) {
      console.log(j(this).attr('class'));
    });

  });

The html code for the element that will be triggered looks like below:

<ul class="wcarchive-terms-list">
    <li class="wcarchive-term wcarchive-term-parent woof_term_224">
        <label class="wcarchive-term-label open">
            Lidingo
        </label>
    </li>
</ul>

When I trigger a Click event from the sub menu, I want to check if .wcarchive-term-label has a class called open

Do you know how can i achieve this within the code:

  j('.menu-item-lidingo').click(function(e) {
    console.log(j(this).attr('class'));

    j('.woof_term_224 > label').click(function(e) {
      console.log(j(this).attr('class'));
    });

  });

Any help is appreciated. Thanks

You could use .trigger;

j('.woof_term_224 > label').click(function(e) {
      if($(this).hasClass("open")){
        console.log("this has been opened!");
      }
      console.log(j(this).attr('class'));
    });

j('.woof_term_224 > label').trigger("click");

It could be more better to use live click function like

j(document).on("click", ".woof_term_224 > label",function(e) {
      if($(this).hasClass("open")){
        console.log("this has been opened!");
      }
      console.log(j(this).attr('class'));
    });

j('.woof_term_224 > label').trigger("click");

Than this could be trigger by JQuery function too. Thanks