0

My onclick function won't work when clicking images inside a modal. I've tried making use of jqueries .on() method as well as targeting the parent and the image element but it still wont work.

the html loaded into the modal

   <div id="imageContent" style="display:none;">
                   <img class="imageUserIcon" src="/Content/Images/UserIcons/1.png" />
                   <img class="imageUserIcon" src="/Content/Images/UserIcons/2.png" />
                   <img class="imageUserIcon" src="/Content/Images/UserIcons/3.png" />
                   <img class="imageUserIcon" src="/Content/Images/UserIcons/4.png" />
               </div>

<img id ="RegisterUserIcon" src="/Content/Images/UserIcons/default.png"/>

the jquery

$('#RegisterUserIcon').click(function () {
    $('#RegisterUserIcon').popModal({
        placement: "bottomCenter",
        html: $('#imageContent').html()
    });
});

    $('.imageUserIcon').on('click', function () {
    alert("hellO");
});
Stevie Wonder
  • 119
  • 1
  • 1
  • 9

0 Answers0