Created
April 29, 2020 11:35
-
-
Save DoubleMarv/23362df4c3dfc0c8855023d667f0ca85 to your computer and use it in GitHub Desktop.
dynamically add mp4 video from data-src to src
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//html | |
<video muted loop data-src="vid/packaging.mp4" id="internalbannervideo"> | |
<source src="" type="video/mp4"> | |
</video> | |
//js | |
function swapVidSource() { | |
var vidplayer = document.getElementById("internalbannervideo"); | |
var thedata = vidplayer.getAttribute('data-src'); | |
vidplayer.src = thedata; | |
vidplayer.play(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment