1

我买了一个 WordPress 主题,我遇到了几个错误,希望能解决我的 BuddyPress 与主题的 jQuery 和 AJAX 的冲突。

我的问题是我收到 2 个错误:

  1. Uncaught TypeError: Cannot call method 'getElementsByTagName' of null

    init:function(tabid, dselected){ var menuitems=document.getElementById(tabid).getElementsByTagName("a")

    Error: Uncaught TypeError: Cannot call method 'getElementsByTagName' of null (repeated 2 times)

  2. Uncaught TypeError: Cannot call method 'getElementsByTagName' of null

    buildcontentdivs:function(setting){ var alldivs=document.getElementById(setting.id).getElementsByTagName("div")

    Error: Uncaught TypeError: Cannot call method 'getElementsByTagName' of null

我不知道如何解决这个问题,因为我不是程序员。我只知道 HTML、CSS 和基本的 WordPress PHP。

4

2 回答 2

1

在每种情况下,getElementById 都没有找到所需的元素。由于您没有为这些调用提供任何上下文,因此无能为力。

于 2012-09-23T12:10:25.200 回答
0

在渲染元素之前,您不能将 jquery 放入<head>它运行的程序中,这就是它可能返回 null 的原因。

于 2012-11-05T05:53:04.347 回答