Event Listeners

I have a general question about event listeners. I am trying to understand how to reattach an event listener after it has been removed due to the element re-rendering.

The project I am working on requires input fields to be hidden until a specific option is selected from a drop down menu. After the first selection, the input fields either: don’t appear if the first selection wasn’t the one to trigger the fields to appear, or the input fields won’t disappear if a different selection is made after first selecting the specific option to make them appear. The goal is to have the fields appear or disappear based on the dropdown selection.

I am listening to the dropdown for any ‘change’. I saw some stuff mentioning the use of a mutation observer but I wasn’t really understanding it.

Thought I would put this out there to see if anyone has found a solid solution or may have a better way of explaining it so I can understand what to do.

Thanks!

If you’d like any more information about mutation observer’s please let me know

1 Like

Thank you I appreciate all the info. I found I wasnt selecting a stable parent container, but now it works as specified. Thanks again!