I have already looked at several examples here on this site but my problem still persists.
Let me explain briefly: I have a series of if / if else that must return the corresponding div to me, based on the type. And so far there are no problems.
Now I want that, in case the type is missing, it will return me a hidden div, therefore not visible
I tried as written below, but for example, if the youtube video is missing, a picture with a black border and a white background appears. I would like to eliminate this "picture" because it is not a good practice to show.
How come it doesn't work like I did?
<div > <iframe id="idframe" width="600" height="400" > </iframe> </div> <br>
else if
.
.
.
else if (myArray.Items[2].type == "video"){
document.getElementById("idframe").src = "https://www.youtube.com/embed/" idurl;
}
else if(myArr.Items[2]type == ""){
document.getElementById("idframe").style.display='none';
}
.video {
display: block;
margin-left: auto;
margin-right: auto;
text-align: center;
}
CodePudding user response:
I think the there is an issue with this line:
document.getElementById("").style.display='none';
maybe you miss id here in getElementById("")
CodePudding user response:
You stated that if the video is missing, a picture appears.
Have you checked that the array item returns a blank value, and not some other value?
Perhaps it would be better to have a catch all instead:
For example:
else {
document.getElementById("idframe").style.display='none';
}
