I am trying to embed a video in a bootstrap modal for an assignment and I haven’t a clue why I cant get it to work.
I tried this iteration
<h3 id = "giza_Pyramid" data-toggle="modal" data-target="#pyramid";>The Giza Pyramids</h3>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Sit culpa eligendi enim suscipit voluptatibus consequatur pariatur aut incidunt quo dicta, cumque quidem iste recusandae esse explicabo modi voluptatem, eum optio.
</p>
<script>
if (
document
.querySelector("#giza_Pyramid")
.addEventListener("click", function () {
document.querySelector("#modal_body").textContent = (
<video class ="giza_Pyramid" width = "450" height = "350" controls src= "Media/gizapyramids.mp4"></video>
);
})
);
</script>
This is basically what I’m using to make it work but when I try it I get a error shown below.
Uncaught SyntaxError: expected expression, got '<'
Any advice on any other functions I can try that would be able to help
2
Answers
Please try this:
Reason to use the innerHTML because the contain have the HTML tags.
Thanks.
Instead of setting
textContent
, setinnerHTML
of the modal body directly like this: