I am looking to trigger an event by clicking on one element and extracting the ID from a separate, unrelated div.
Here is my attempt:
$(".map_flag").on("click",function(){
var selectedID = ($(this).attr("data_modal"));
$("#" + selectedID).fadeIn(300, function(){
$("#" + selectedID).find(".modal_content").fadeIn(300);
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button class="map_flag" data_modal="map_1">
<img src="img/image_1.png" alt="image one" >
</button>
<div id="map_1">
<p class="modal_content">place holder</p>
</div>