Is it possible to use JQuery to hide a div when another div is clicked, even if the div to be hidden is only created upon clicking?
Consider the following code example:
HTML:
<div class="first">Click here to create the second div</div>
<div class="second">This div appears only after the first div is clicked</div>
The current situation was implemented by a different developer's code.
I want to add my own code to ensure that the second div is hidden immediately after the first div is clicked, without altering the original code.
This is the JQuery code I have attempted so far:
$(".first").on("click",function() {
$(".second").hide();
});