未捕获的TypeError:无法读取null的属性“ button”

时间:2019-02-14 20:21:15

标签: jquery

我有一个运行自定义主题的OS Commerce商店。在我的控制台中,我看到以下错误:

未捕获的TypeError:无法读取null的属性“按钮”

有问题的行是:

<li><span class="tdbLink"><a id="tdb1" href="/index.php">Home</a></span><script type="text/javascript">$("#tdb1").button().addClass("ui-priority-secondary").parent().removeClass("tdbLink");</script></li>

该错误没有多大意义,因为我相信button()方法将强制所选元素的行为类似于按钮。我可以看到锚链接具有选择器使用的ID,那么为什么将属性报告为null?

我认为这可能与js库的包含方式有关。在页面顶部引用了它们,如下所示:

<script type="text/javascript" src="//google-analytics.com/analytics.js"></script>
<script src="//code.jquery.com/jquery-1.11.2.min.js"></script>
<script src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
<script type="text/javascript" src="ext/jquery/bootstrap.js"></script>
<script type="text/javascript" src="ext/jquery/bootstrap.min.js"></script>
<script type="text/javascript" src="ext/jquery/jquery.cookiebar.js"></script>
<script type="text/plain" class="cc-onconsent-inline-advertising" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>

<script type="text/javascript" src="ext/photoset-grid/jquery.photoset-grid.min.js"></script>
<link rel="stylesheet" type="text/css" href="ext/colorbox/colorbox.css" />

<script type="text/javascript" src="ext/colorbox/jquery.colorbox-min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script type="text/javascript" src="ext/jquery/jquery.carouFredSel-6.0.4-packed.js"></script>
<script type="text/javascript" src="ext/jquery/jquery.flexslider.js"></script>
<script type="text/javascript" src="ext/jquery/osmart.js"></script>
<script type="text/javascript" src="ext/jquery/tabcontent.js"></script>
<script type="text/javascript" src="ext/jquery/css_browser_selector.js"></script>

看起来有两个版本的jquery正在使用,这似乎是不好的做法,这意味着什么?

更新

我已删除了重复的js文件,因此现在有了:

<script type="text/javascript" src="//code.jquery.com/jquery-1.12.4.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js" integrity="sha256-VazP97ZCwtekAsvgPBSUwPFKdrwD3unUfSGVYrahUqU=" crossorigin="anonymous"></script>
<script type="text/javascript" src="ext/jquery/bootstrap.min.js"></script>
<script type="text/javascript" src="ext/jquery/jquery.cookiebar.js"></script>
<script type="text/plain" class="cc-onconsent-inline-advertising" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript" src="//google-analytics.com/analytics.js"></script>
<script type="text/javascript" src="ext/photoset-grid/jquery.photoset-grid.min.js"></script>
<script type="text/javascript" src="ext/colorbox/jquery.colorbox-min.js"></script>
<script type="text/javascript" src="ext/jquery/jquery.carouFredSel-6.0.4-packed.js"></script>
<script type="text/javascript" src="ext/jquery/jquery.flexslider.js"></script>
<script type="text/javascript" src="ext/jquery/osmart.js"></script>
<script type="text/javascript" src="ext/jquery/tabcontent.js"></script>
<script type="text/javascript" src="ext/jquery/css_browser_selector.js"></script>

我仍然看到与以前相同的错误。

0 个答案:

没有答案