Javascript – trigger parent click event when child is clicked

eventshtmljavascriptjquery

I'n new to javaScript and jQuery. How is this possible to call the click event of parent element when you click its child?
I have this structure in my code:

<ul id="pc5">
   <li><a href="#">book</a>
   </li>
</ul>

I want something like this:

$("a").click(ul.click);

Any help would be appreciated.

EDIT: in my ul click function I need ul id attribute. something like this:

 ul.click(function(e){alert(e.target.id);

so when link is clicked, event.target isn't ul element.

Best Answer

If your child element is located inside your parent element you could also just add this CSS property.

.child {
   pointer-events: none
}

This way the click directly triggers the parent's click event listener.

This feature's support is quite good.