让HTML5“按钮”标签在浏览器中运行

时间:2012-01-11 20:13:27

标签: html5 button

我目前正在使用HTML5开展大学项目。 我一直在使用按钮标签编写所有代码。 我一直在使用chrome测试网站,但是,刚刚注意到虽然按钮出现在IE和Firefox中,但它们不起作用。

有没有办法解决这个问题?或者按钮标签在这些浏览器中不起作用?

这是在Chrome中完美运行的代码,但不适用于其他浏览器。

<div class="option" id="question1" style="display:none">
<p> Which way do you think the criminals have fled?</p>
<p>Up the Stairs <button class="arrow" id="stairs"><a href="upstairs.html"><img src="images/arrow.png" width="15" height="15"/></a></button></p>
<p>Down the Alley <button class="arrow" id="alley"><a href="alley.html"><img src="images/arrow.png" width="15" height="15"/></a></button></p>
</div>

1 个答案:

答案 0 :(得分:2)

button元素不能包含交互式后代。因此,您不能将a标记作为button元素的子标记。只需从a中删除button标记,然后根据需要更改代码。

有关详细信息,请阅读button Element in the HTML Specification

实施例

<div class="option" id="question1" style="display:none;">
<p>Which way do you think the criminals have fled?</p>
<p>Up the Stairs <button class="arrow" id="stairs"><img src="images/arrow.png" width="15" height="15"></button></p>
<p>Down the Alley <button class="arrow" id="alley"><img src="images/arrow.png" width="15" height="15"></button></p>
</div>