jQuery .click(function() 在 Firefox 中不工作

jQuery .click(function() not working in Firefox

我正在尝试在用户使用 jQuery 单击保留图像时加载 YouTube iFrame。这在除 Firefox 之外的所有浏览器中都可以正常工作。

知道是什么导致了这个问题吗?

如需现场示例,请访问 http://roelto.com/ 并单击主图像。您会在 Chrome、Safari、IE 中看到 iframe 加载正常,但在 Firefox

中却看不到

这是我正在使用的 jQuery...

<script>
  jQuery(document).ready(function() {
    jQuery('#dna_video_thumbnail').click(function() {
      jQuery('<iframe width="560" height="315" src="//www.youtube.com/embed/uIYa7RiDjs8" frameborder="0" allowfullscreen></iframe>').prependTo('#dna_video');
      jQuery(this).remove();
    });
  });
</script>

使用这个:

 $(document).on('click','yourelement',function(){ 
$('<iframe width="560" height="315" src="//www.youtube.com/embed/uIYa7RiDjs8" frameborder="0" allowfullscreen></iframe>').prependTo('#dna_video');
      $(this).remove();
});

您正在调用函数 getHeight();在 dna_script.js 的第 125 行。它是未定义的。您可以在 Firefox 的控制台中看到它。

将函数声明移到函数调用之上。