【问题标题】:radio button working in google chrome but not in firefox单选按钮在谷歌浏览器中工作,但在 Firefox 中不工作
【发布时间】:2016-02-18 23:16:44
【问题描述】:

在我看来,单选按钮在 google chrome 中有效,但在 firefox 中无效。请告诉我会出现什么问题?

查看:

<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>

【问题讨论】:

  • 你能提供一些sn-ps的代码吗?另外,“不工作”是什么意思?
  • 单选按钮不起作用意味着当我单击单选按钮时,它没有任何功能。

标签: html google-chrome firefox radio-button


【解决方案1】:

这不起作用的原因是 input 元素嵌套在 button 元素中。严格来说,这不允许作为 button 元素 (https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Content_categories#Phrasing_content) 中的内容。

比 Chrome 更符合标准的 Firefox 不允许这样做。有很多方法可以破解这个,但我强烈建议不要使用button 标签。如果您需要这些元素看起来像按钮,请使用 CSS。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-09-20
    • 1970-01-01
    • 1970-01-01
    • 2016-05-07
    • 1970-01-01
    • 2012-11-14
    • 1970-01-01
    相关资源
    最近更新 更多