---
title: "Comment by Purvi Barot on \"Bubbling in JavaScript?\" | Hashnode"
description: "When an event happens on an element, it first runs the handlers on it, then on its parent, then all the way up on other ancestors. Let’s say we have 3 nested el"
url: "https://hashnode.com/posts/bubbling-in-javascript/5d3faf35ea67aca069f055cf/comment/5ea14afe12892a3c760b4212"
---

[Discussion](https://hashnode.com/posts/bubbling-in-javascript/5d3faf35ea67aca069f055cf)

Comment [Bubbling in JavaScript?](https://hashnode.com/posts/bubbling-in-javascript/5d3faf35ea67aca069f055cf)

[Purvi Barot](https://hashnode.com/@purvi)

[Apr 23, 2020](https://hashnode.com/posts/bubbling-in-javascript/5d3faf35ea67aca069f055cf/comment/5ea14afe12892a3c760b4212)

When an event happens on an element, it first runs the handlers on it, then on its parent, then all the way up on other ancestors.

Let’s say we have 3 nested elements : form , div, p .

```
<form onclick="alert('form')">form
  <div onclick="alert('div')">div
    <p onclick="alert('p')">p</p>
  </div>
</form>
```

```
<style>
  body * {
    margin: 10px;
    border: 1px solid blue;
  }
</style>
```

If we click on p tag,then see 3 alerts - p ,div,from. The process is called “bubbling”.
