javascript - jquery 表折叠在 ie11.035 和 firefox 46.0.1 上不起作用

标签 javascript jquery browser html-table collapse

关于浏览器兼容性的一个小问题。

我有这个代码来扩展和减少一个 html 表的 tbody:

  <script type="text/javascript" src="http://code.jquery.com/jquery-1.5.2.js"></script>
  <style type="text/css">

  </style>
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/jquery-ui.js"></script>
  <script type='text/javascript'>//<![CDATA[
 $(document).ready(function () {
        $(".expand").click(function () {
            $("#mytable tbody").show("slow");
        });
        $(".collapse").click(function () {
            $("#mytable tbody").hide("fast");
        });
    });

</script>
<center>

<table border="1" width="1200px"  id="mytable">
<thead>
<tr>
<td style="border:red 0px solid"></td>
<td><b>Numero</b></td>
<td><b>Data apertura</b></td>
<td><b>Data scadenza</b></td>
<td><b>Data chiusura</b></td>
<td><b>Competenza</b></td>
<td><b>Priorità </b></td>
<td><b>File caricati</b></td>
<td><b>Assegnata a</b></td>
<td><b>Tipo ricontatto</b></td>
<td><b>Stadio</b></td>
<td><b>Stato</b></td>
<td style="width:80px"><a class="expand" href="#"><button type="button" style="width:100%" >Espandi</a></button></td>
</tr>

<tr class="clickable">
<td>Pallino</td>
<td>1-2016</td>
<td>10/09/2016</td>
<td>25/10/2016</td>
<td></td>
<td>caf</td>
<td>alta</td>
<td></td>
<td>delegato</td>
<td>78576</td>
<td>presa in carico</td>
<td>aperta</td>
<td style="width:80px"><a class="collapse" href="#"><button type="button" style="width:100%">Riduci</a></button></td>
</tr>
</thead>

<tbody style="display:none;">
<tr>
<td colspan="2"><b>Descrizione</b></td>
<td colspan="11">testo Descrizione</td>
</tr>

<tr>
<td colspan="2"><b>Note</b></td>
<td colspan="11">testo Note</td>
</tr>

<tr>
<td colspan="2"><b>Note delegato</b></td>
<td colspan="11">Note delegato</td>
</tr>

<tr>
<td colspan="13"><center>
<input name="Modifica" type="submit" value="Modifica"/> &nbsp;
<input type="reset" value="Cancella"> &nbsp;
<input type="button" value="Annulla" onclick="window.location='privata.php';"></center>
</td>
</tr>
</tbody>
</table>

它适用于 Chrome 和 Edge,但不适用于 IE 和 Firefox,我不知道为什么。我取了http://jsfiddle.net/Trufa/b3pTg/1/中的代码,并且该页面可在所有提到的浏览器中运行。

有人能告诉我为什么它不在我的上运行,我该如何解决?

最佳答案

您好您的 html 代码有一些错误:
请看看这个:

<td style="width:80px"><a class="expand" href="#"><button type="button" style="width:100%" >Espandi</a></button></td>

它应该被替换为:
<td style="width:80px"><a class="expand" href="#"><button type="button" style="width:100%" >Espandi</button></a></td>

更改代码后即可使用。

最好的祝福

关于javascript - jquery 表折叠在 ie11.035 和 firefox 46.0.1 上不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39584441/

相关文章:

javascript - 使用 CSS 制作二进制数动画

javascript - Vue 3 在 onMounted 中显示之前的路线

javascript - 在 jQuery 上按元素内部的类选择项目

javascript - 如何使 jQuery ui datepicker 按钮图像只读

jquery - jquery 的基本快速 ajax 问题

javascript - 如何使用元素上的指针事件禁用整个页面的滚动?

javascript - 使用过渡更改 Canvas 上的图像

javascript - 如何使用 jQuery 循环遍历 HTML 元素和 JSON?

javascript - 将文本从剪贴板粘贴到 Firefox 和 Chrome

qt - 在某个浏览器选项卡/窗口中打开一个 URL