I work locally with Bootstrap, jQuery and HTML. When you click the button button
, you get the URL of the data that fits in the iframe video. If you put an empty one src=""
, it will be much faster than not placing anything. Why is this? Apparently, that doesn't seem to matter.
Example:
<script>
var youtube = "https://www.youtube.com/embed/"
$("button[data-url]").click(function() {
var code = $(this).data("url")
var video = youtube + code
$("iframe").attr("src", video)
})
</script>
<button type="button" data-url="WhateverCode1">Video 1</button>
<button type="button" data-url="WhateverCode2">Video 2</button>
<div class="embed-responsive embed-responsive-16by9">
<iframe class="embed-responsive-item" src=""></iframe>
</div>
<div class="embed-responsive embed-responsive-16by9">
<iframe class="embed-responsive-item"></iframe>
</div>
source
share