[英]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"> </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.