我正在尝试构建一个应用程序,以根据类别查看YouTube视频。用户会显示一个类别的下拉列表,他会选择一个类别。 div'rContent'填充了该类别中的链接列表。当用户点击其中一个链接时,YouTube视频会在iframe中打开。问题出在用户点击链接时,视频在Firefox中显示,但在Chrome中无法使用。什么都没发生。动态生成的HTML链接在Firefox中工作,但在Chrome中不起作用
<!-- Dynamically retrieved list of videos shown here, see sample below -->
<div id="rContent"></div>
<!-- YouTube video will be shown in this iframe-->
<div class="video-container">
<iframe id="userVideo" src="" frameborder="0" width="560" height="315"></iframe>
</div>
<script>
$("#rContent").on('click', '.vid_trigger', function() {
var URL = $(this).attr('href');
$(userVideo).attr('src',URL)
return false;
});
</script>
<!--- sample of dynamic content -->
<a class="vid_trigger" href="http://www.youtube.com/embed/fgqpHl5OGFA?rel=&autoplay=1"> … </a><br></br>
<a class="vid_trigger" href="http://www.youtube.com/embed/c-d4rDY70zk?rel=&autoplay=1"> … </a><br></br>
什么是变量'userVideo'设置为?如果未设置,则缺少引号和'#'。 – mash
谢谢!你是对的。 –