How To Solve span Problem In Blogger Template?


#1

Hello Everyone ! Specially @Shivansh @Mohammad @ & @Nitishk

Please Solve This One…

When i’m Tryna Save This JavaScript Code…

// Get the <span> element that closes the modal
var span = document.getElementsByClassName("close")[0];

// When the user clicks on <span> (x), close the modal
span.onclick = function() {
    modal.style.display = "none";
}

This One Error i Found The element type “span” must be terminated by the matching end-tag "</span>".

Please Solve ASAP…

I’m Waiting…


#3

This problem is not occuring because of that code, but because of your template. Check out any <span> tag in your template that comes before this code and is not closed be another </span>.


#4

No @Shivansh I Got This Error Where I Put This Above Code.


#5

Actually @shivansh not used his eagle’s eye which he always use. :wink:

The JS code you have mentioned above already include <span> tag so you have to save it as like this.

<script type='text/javascript'>
//<![CDATA[
// Get the <span> element that closes the modal
var span = document.getElementsByClassName("close")[0];

// When the user clicks on <span> (x), close the modal
span.onclick = function() {
    modal.style.display = "none";
}
//]]>
</script>

It will work for you @paaris_sohail


#6

Actually Full Code Is Here

<script>
// 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('myImg');
var modalImg = document.getElementById("img01");
var captionText = document.getElementById("caption");
img.onclick = function(){
    modal.style.display = "block";
    modalImg.src = this.src;
    modalImg.alt = this.alt;
    captionText.innerHTML = this.alt;
}
// Get the <span> element that closes the modal
var span = document.getElementsByClassName("close")[0];

// When the user clicks on <span> (x), close the modal
span.onclick = function() {
    modal.style.display = "none";
}

</script>

#7

Remove and save it as below

 <script type='text/javascript'>
//<![CDATA[
// 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('myImg');
var modalImg = document.getElementById("img01");
var captionText = document.getElementById("caption");
img.onclick = function(){
    modal.style.display = "block";
    modalImg.src = this.src;
    modalImg.alt = this.alt;
    captionText.innerHTML = this.alt;
}
// Get the <span> element that closes the modal
var span = document.getElementsByClassName("close")[0];

// When the user clicks on <span> (x), close the modal
span.onclick = function() {
    modal.style.display = "none";
}
//]]>
</script>

It will work for you. :slight_smile:

Tell me if problem persist.