Currently, I am working on developing a movie information application using ajax. However, I have encountered a challenging issue that I am struggling to resolve. After creating an ajax request, I proceed to dynamically generate content and incorporate it into the webpage. Here is an example of my dynamically created content:
output +=
`<div class="box">
<div class="box-image">
<img src="${val.Poster}" alt="${val.Title}">
</div>
<div class="box-body">
<h4 class="box-title">${val.Title}</h4>
<p class="year">${val.Year}</p>
<a href="#" class="modal-trigger" id="modalTrigger">Modal Trigger</a>
</div>
</div>`.
My challenge lies in implementing a function for the anchor tag in order to open a modal. Additionally , I am searching for a way to prevent its default behavior within this function.