Attach an event listener to a parent element that fires when an event occurs on a child element.
Event PropagationWhen an event moves through the DOM from child to a parent element, that's called Event Propagation, because the event propagates, or moves through the DOM.
In this example, an event (onclick) from a button gets passed to the parent paragraph.
$(document).ready(function() {_x000D_
_x000D_
$(".spoiler span").hide();_x000D_
_x000D_
/* add event onclick on parent (.spoiler) and delegate its event to child (button) */_x000D_
$(".spoiler").on( "click", "button", function() {_x000D_
_x000D_
$(".spoiler button").hide(); _x000D_
_x000D_
$(".spoiler span").show();_x000D_
_x000D_
} );_x000D_
_x000D_
});
_x000D_
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>_x000D_
_x000D_
<p class="spoiler">_x000D_
<span>Hello World</span>_x000D_
<button>Click Me</button>_x000D_
</p>
_x000D_