在 google chrome 中工作但在 firefox 中不工作的单选按钮
radio button working in google chrome but not in firefox
在我看来,单选按钮在 google chrome 中有效,但在 firefox.please 中无效,告诉我会出现什么问题?
查看:
<div class="btn-group btn-group" role="group" aria-label="...">
<button type="button" class="btn btn-default" >
<input type='radio' name="property" value="1" id="home" >
Home
</button>
<!--style="background-color: #0eaaa6"-->
<button type="button" class="btn btn-default" >
<input type='radio' name="property" value="2" id="plot" >
Plot
</button>
<button type="button" class="btn btn-default" >
<input type='radio' name="property" value="3" id="commercial" >
Commercial
</button>
这不起作用的原因是您有 input
个元素嵌套在 button
个元素中。严格来说,这不允许作为 button
元素 (https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Content_categories#Phrasing_content) 内的内容。
比 Chrome 更符合标准的 Firefox 不允许这样做。有多种方法可以解决这个问题,但我强烈建议不要使用 button
标签。如果您需要这些元素看起来像按钮,请使用 CSS.
在我看来,单选按钮在 google chrome 中有效,但在 firefox.please 中无效,告诉我会出现什么问题?
查看:
<div class="btn-group btn-group" role="group" aria-label="...">
<button type="button" class="btn btn-default" >
<input type='radio' name="property" value="1" id="home" >
Home
</button>
<!--style="background-color: #0eaaa6"-->
<button type="button" class="btn btn-default" >
<input type='radio' name="property" value="2" id="plot" >
Plot
</button>
<button type="button" class="btn btn-default" >
<input type='radio' name="property" value="3" id="commercial" >
Commercial
</button>
这不起作用的原因是您有 input
个元素嵌套在 button
个元素中。严格来说,这不允许作为 button
元素 (https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Content_categories#Phrasing_content) 内的内容。
比 Chrome 更符合标准的 Firefox 不允许这样做。有多种方法可以解决这个问题,但我强烈建议不要使用 button
标签。如果您需要这些元素看起来像按钮,请使用 CSS.