Javascript代码不工作在Chrome,但工作在其他任何地方

Javascript Code not working in Chrome, but works everywhere else

本文关键字:工作 其他 任何地 Chrome 代码 Javascript      更新时间:2023-09-26

我试图在表头上调用jquery单击函数,用可排序插件对其进行排序。

jQuery("#orderby").click();

此代码通常被安排在文档准备好后几毫秒工作,否则它将无法工作。我在火狐上检查了一下,一切正常。然后是Chrome,什么都没有,Safari也没有。我已经检查了IE和Opera,它确实工作得很好。

我通过Chrome的控制台尝试过,它也不起作用。你知道我错过了什么吗?如果你需要更多的细节,请问。

<table title="Clasificaciones" summary="" class="leaguemanager standingstable sortable">
      <thead>
        <tr>
          <th class="logo num">&nbsp;</th>
          <th>Equipo</th>
          <th id="orderby">GC</th>
          <th>Loc</th>
          <th>Vis</th>
        </tr>
      </thead>
      <tbody>
        <tr class="alternate ascend">
          <td class="logo"><img title="Logo" alt="Logo" src="#"></td>
          <td><a href="#">Cruz Azul</a></td>
          <td class="num">7</td>
          <td class="num">4</td>
          <td class="num">3</td>
        </tr>     
      </tbody>
      <tfoot>
      </tfoot>
    </table>

上面的JS就是所有被调用的。

表头你指的是一个<thead> ?有可能Chrome不处理点击事件的头部

据我所知,您正在尝试模拟表头上的单击事件。click()不这样做——该方法用于定义单击处理程序函数。

尝试使用以下代码来模拟表头上的单击事件:

jQuery("#orderby").trigger(jQuery.Event("click"));
相关文章: