我的代码中有一些错误这是我的错误:
label元素的for属性必须引用非隐藏的表单控件.
和myd代码:
<form action="/search">
<span class="input input--hoshi search-wrapp main-page-open" style="display:block">
<input class="input__field input__field--hoshi" type="text" id="search" name="keyword" placeholder="Search..."/>
<label class="input__label input__label--hoshi input__label--hoshi-color-2" for="input-5">
<!--<span class="input__label-content input__label-content-hoshi">Search...</span>-->
</label>
<span class="icon-serch"></span>
</span>
<input id="search-btn" type="submit" style="display: none;"/>
</form>Run Code Online (Sandbox Code Playgroud)
这有什么问题?谢谢!
该用于标签属性必须包含输入ID值
<label for="foo">Foo:</label>
<input id="foo">
Run Code Online (Sandbox Code Playgroud)
要省略for和id属性,将输入放在label中
<label>
Foo: <input name="foo">
</label>
Run Code Online (Sandbox Code Playgroud)
另请注意,该输入无法隐藏 <input type="hidden">,但可以将其设置为隐藏<input style="display:none">
验证器期望标签的for字段以id包含它的输入元素的字段为目标。在这里,这意味着for="input-5"预期为for="search",因为<input>的 id 是search。
由于您期望用户向该字段添加输入,因此您应该确保它们相互链接。
| 归档时间: |
|
| 查看次数: |
11193 次 |
| 最近记录: |