单击 jQuery 按钮更改 iFrame 的 URL?
Change URL of iFrame with jQuery button click?
我想知道如何在单击蓝色按钮后更改此 iframe 中的视频。
因此,换句话说,单击蓝色按钮将更改 iframe 中正在播放的视频。
如果有人知道如何做到这一点,请告诉我...
HTML
<div id="stage">
<iframe width="560" height="315" src="https://www.youtube.com/embed/e-ORhEE9VVg" frameborder="0" allowfullscreen></iframe>
</div>
<br>
<div id="button">Click me</div>
CSS
#button{
background:blue;
cursor:pointer;
width:200px;
margin-left:auto;
margin-right:auto;
color:white;
}
jQuery
$(document).on('click', '#button', function(event) {
});
考虑一下:
$( "#button" ).click(function() {
$("#stage > iframe").attr("src", "http://www.wp.pl");
});
其中 http://www.wp.pl
只是一个 link 供您替换。您可以随时尝试使用某种循环来获得更多歌曲。
我想知道如何在单击蓝色按钮后更改此 iframe 中的视频。 因此,换句话说,单击蓝色按钮将更改 iframe 中正在播放的视频。
如果有人知道如何做到这一点,请告诉我...
HTML
<div id="stage">
<iframe width="560" height="315" src="https://www.youtube.com/embed/e-ORhEE9VVg" frameborder="0" allowfullscreen></iframe>
</div>
<br>
<div id="button">Click me</div>
CSS
#button{
background:blue;
cursor:pointer;
width:200px;
margin-left:auto;
margin-right:auto;
color:white;
}
jQuery
$(document).on('click', '#button', function(event) {
});
考虑一下:
$( "#button" ).click(function() {
$("#stage > iframe").attr("src", "http://www.wp.pl");
});
其中 http://www.wp.pl
只是一个 link 供您替换。您可以随时尝试使用某种循环来获得更多歌曲。