javascript - 按钮在 Mozilla Firefox 中不起作用,但在 Google Chrome 中不起作用

标签 javascript html firefox button anchor

我的表单有两个按钮,可在 Google Chrome 中正常工作,但在 Mozilla Firefox 中无法工作。我应该做什么?

<td>
    <button type="button">
        <a href="edit_teacher.php?edit=<?php echo $row['teach_id']; ?>">
            <span class="glyphicon glyphicon-edit" style="font-size: 20px; color: green;"></span>
        </a>
    </button>
</td>
<td>
    <button type="button">
        <a href="delete_teach.php?del=<?php echo $row['teach_id']; ?>" onclick="return confirm('The Record will be Deleted....???');">
            <span class="glyphicon glyphicon-trash" style="font-size: 20px; color: #ac2925;" ></span>
        </a>
     </button>
</td>

最佳答案

a 标记放在 button 标记之外。否则按钮将消耗该事件。

<td><a href="edit_teacher.php?edit=<?php echo $row['teach_id']; ?>"><button type="button"><span class="glyphicon glyphicon-edit" style="font-size: 20px; color: green;"></span></button></a></td>
<td><a href="delete_teach.php?del=<?php echo $row['teach_id']; ?>" onclick="return confirm('The Record will be Deleted....???');"><button type="button"><span class="glyphicon glyphicon-trash" style="font-size: 20px; color: #ac2925;" ></span></button></a></td>

HTML5 spec for button实际上使得将交互内容放入按钮内无效。

Content model:

Phrasing content, but there must be no interactive content descendant.

因此 Firefox 理所当然地禁止与按钮内的内容进行交互。

关于javascript - 按钮在 Mozilla Firefox 中不起作用,但在 Google Chrome 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33449047/

相关文章:

javascript - Adobe Acrobat Pro DC 自定义计算脚本建议

php - 在 codeigniter 中设置基本 url

javascript - 复制 URL 参数并粘贴到 HTML 上

firefox - Linux 上的 headless 、可编写脚本的 Firefox/Webkit?

html - 页脚区域的 Firefox 位置问题?

javascript - 如何获取对div的引用?

javascript - (Nodejs + Restify)发送后无法设置标题 - promise 拒绝警告

javascript - 使用 jQuery 检查列表中第一个可用/缺失的 id?

javascript - 是否可以使用 document.querySelector() 获取多个 ID?

javascript - 无法获取对现有窗口的引用