我想在不影響嵌套<input>
標籤的情況下禁用或隱藏內容「分組」 <label>
標籤。隱藏標籤
<label class="" for="officersheet_fields_attributes_3_grouping">
<input type="checkbox" id="officersheet_fields_attributes_3_grouping" name="officersheet[fields_attributes][3][grouping]" value="1">
Grouping
</label>`
我在rails中使用formtastic。 formtastic代碼片段 <td><%= f.input :grouping %></td>
上面的代碼生成上面的html代碼。
在此先感謝
把'input'放在'label'裏面怎麼回事? W3C表示,可以在'input'> http://www.w3.org/TR/html401/interact/forms.html#edef-LABEL – BenM 2013-03-12 09:20:06
之前,之後或周圍放置'label',問題在於它是由rails中的formtastic自動生成的。代碼'<%= f.input:grouping%>' – Tony45 2013-03-12 09:22:15
當然這是可能的,也是有效的。但標籤是輸入控件的可點擊文本。把輸入控制放在裏面不是很乾淨,我想。此外,當你將它們分開時,你會更加靈活。 – 2013-03-12 09:22:22