简体   繁体   English

Javascript代码无法在Chrome中使用,但可以在其他任何地方使用

[英]Javascript Code not working in Chrome, but works everywhere else

I'm trying to call a jquery click function on a table header to sort it with the sortable plugin. 我正在尝试在表头上调用jquery click函数,以使用可排序插件对其进行排序。

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

This code is usually scheduled to work a few milliseconds after document ready because otherwise it wouldn't work. 此代码通常计划在文档准备就绪后几毫秒内生效,因为否则它将无法正常工作。 I was checking it on Firefox and all good. 我在Firefox上检查过它,一切都很好。 Then Chrome and nothing, Safari doesn't get it as well. 然后是Chrome,什么也没有,Safari也没有。 I have checked IE and Opera and it does work well. 我已经检查了IE和Opera,它运行良好。

I tried it through the console in Chrome and it doesn't work either. 我通过Chrome中的控制台进行了尝试,但也无法正常工作。 Any idea what i could be missing? 知道我可能会缺少什么吗? If you need extra details please ask. 如果您需要其他详细信息,请询问。

<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>

The above JS is all that is called. 上面的JS就是全部。

It the table header you are referring to a <thead> ? 您要引用的表头是<thead>吗? It's possible that Chrome doesn't handles click events on theads. Chrome浏览器可能无法处理广告上的点击事件。

As far as I understand you are trying to simulate a click event on the table header. 据我了解,您正在尝试模拟表格标题上的click事件。 click() does not do this - this method is used for defining a click handler function. click()不会执行此操作-此方法用于定义点击处理函数。

Try using this code instead to simulate a click event on your table header: 请尝试使用以下代码来模拟表格标题上的click事件:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么AJAX调用不仅仅适用于iOS,其他任何地方都可以运行得很好? - Why AJAX call is not working only on iOS, everywhere else it works great? Javascript代码在Chrome和firefox中不起作用,但在IE中起作用 - Javascript Code is not working in Chrome and firefox but works in IE 可在Chrome浏览器中运行的Javascript - Javascript that works in Chrome but nothing else Javascript表单脚本适用于Chrome但无处可用 - Javascript form script works Chrome but nowhere else IE10上的forEach不能在Server 2008上运行,但在其他任何地方都可以在IE10上运行 - forEach on IE10 not working on Server 2008, but works on IE10 everywhere else Javascript代码仅在Chrome中有效 - Javascript Code only works in Chrome Javascript代码无法在chrome中使用 - Javascript code not working in chrome 登录模块可在所有地方使用,但Chrome除外 - Login Module works everywhere, except in Chrome 将新条件应用于标头if语句 - 如果URI是某个页面,则不显示显示在站点上其他任何位置的代码 - Working a new condition into a header if statement - if URI is a certain page, don't display code that displays everywhere else on the site JavaScript更改fontsize无处不在 - JavaScript change fontsize not working everywhere
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM