-1

我遇到了一些 jquery 与其他 jquery 冲突的问题......你能告诉我我是否编码正确。

<script type="text/javascript">
jQuery(function(){
    var $mov=$(document);
      $mov.ready(function(){
    (".movie").mb_YTPlayer();
    });
});
</script>
4

2 回答 2

2

你可以试试这个:

//Relinquish jQuery's control of the "$" variable.
$.noConflict();
jQuery(document).ready(function($) {
  // Code that uses jQuery's $ can follow here.
  $(".movie").mb_YTPlayer();
});

使用$.noConflict将允许您使用多个 jQuery 实例或避免使用$.

看起来您只是想包装.mb_YTPlayer()一个准备好的文档。你也失踪$(".movie")

我不确定你想用什么来完成var $mov=$(document);......

于 2013-03-11T01:34:30.180 回答
0

jQuery 函数返回一个对象,因此您的代码是有效的。您可以在变量范围内对变量调用 jQuery 函数。

但我不知道你所说的“一些 jQuery 与其他 jQuery 冲突”是什么意思

于 2013-03-11T01:43:14.727 回答