# Nested onClick events - how to preventDefault?

**URL:** <https://community.weweb.io/t/nested-onclick-events-how-to-preventdefault/4797>\
**Category:** How do I?\
**Created:** [October 9, 2023, 7:43am UTC](https://community.weweb.io/t/nested-onclick-events-how-to-preventdefault/4797 "2023-10-09T07:43:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cam](https://avatars.discourse-cdn.com/v4/letter/c/bbe5ce/32.png) [@Cam](https://community.weweb.io/u/Cam)\
**Post date:** [October 9, 2023, 7:43am UTC](https://community.weweb.io/t/nested-onclick-events-how-to-preventdefault/4797/1 "2023-10-09T07:43:49Z")

</div>

I have an item that I click, and when I click it, I do something. But I also have an item inside of this parent element, that also has its own actions when I click _it_.

But because there must be some kind of event listener on the parent, it triggers this item when I click the child element. Is there any way to go around this? Thanks!

I’ve tried to use event.preventDefault but nothing seems to work. Thanks!

---

<div class="post-metadata">

**Author:** ![Alexis](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/alexis/32/13248_2.png) [@Alexis](https://community.weweb.io/u/Alexis)\
**Post date:** [October 9, 2023, 8:33am UTC](https://community.weweb.io/t/nested-onclick-events-how-to-preventdefault/4797/2 "2023-10-09T08:33:52Z")

</div>

I think it should be `event.domEvent.preventDefault`, you was probably on the right path 🙂

---

<div class="post-metadata">

**Author:** ![Cam](https://avatars.discourse-cdn.com/v4/letter/c/bbe5ce/32.png) [@Cam](https://community.weweb.io/u/Cam)\
**Post date:** [October 9, 2023, 5:21pm UTC](https://community.weweb.io/t/nested-onclick-events-how-to-preventdefault/4797/3 "2023-10-09T17:21:08Z")

</div>

Oo I gotta get familiar with WeWeb’s expected syntax. Thanks!

---

<div class="post-metadata">

**Author:** ![mauromequelussi](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/mauromequelussi/32/10223_2.png) [@mauromequelussi](https://community.weweb.io/u/mauromequelussi)\
**Post date:** [October 10, 2023, 10:20pm UTC](https://community.weweb.io/t/nested-onclick-events-how-to-preventdefault/4797/4 "2023-10-10T22:20:07Z")

</div>

Add the html attribute as in the image in the child element.

 ![WhatsApp Image 2023-10-10 at 19.17.13](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/7/79ff28ae1a3e6e98b6bfeb3c9cda95bef2f9aece.jpeg)

---

<div class="post-metadata">

**Author:** ![Cam](https://avatars.discourse-cdn.com/v4/letter/c/bbe5ce/32.png) [@Cam](https://community.weweb.io/u/Cam)\
**Post date:** [October 10, 2023, 11:44pm UTC](https://community.weweb.io/t/nested-onclick-events-how-to-preventdefault/4797/5 "2023-10-10T23:44:47Z")

</div>

Awesome, thanks!
