unable to set property 'onclick' of undefined and img
please help me
THIS is my modal.js file code
- // Get the modal
- var modal = document.getElementById('myModal');
- // Get the image and insert it inside the modal - use its "alt" text as a caption
- var img = document.getElementById('<%= ImgProfile.ClientID %>');
- var modalImg = document.getElementById("img01");
- //var captionText = document.getElementById("caption");
- img.onclick = function () {
- alert("hello");
- modal.style.display = "block";
- modalImg.src = this.src;
- // captionText.innerHTML = this.alt;
- }
- // Get the element that closes the modal
- var span = document.getElementsByClassName("close")[0];
- // When the user clicks on (x), close the modal
- span.onclick = function() {
- modal.style.display = "none";
- }
THIS is my home.aspx file code
- <asp:Image ID="ImgProfile" runat="server" src="Images/19251082_10215259476544325_53831408_n.jpg" CssClass="img-thumbnail"/>
- <div id="myModal" class="modal">
- <span class="close">×span>
- <img class="modal-content" id="img01" />
- <div id="caption">div>
- div>
Gajendra JangidPosted Feb 2, 2018, 5:33 AM