html - select 元素是否具有 required 属性?

标签 html attributes html-select

select元素是否有required属性?

最佳答案

是的,您可以在 HTML5 中使用 required 属性。但请记住,第一个值应该为空。

<select required>
<option value="">Please select</option>
<option value="first">First</option>
</select>

这里有更多例子:

http://dev.w3.org/html5/spec-author-view/the-select-element.html#the-select-element

关于html - select 元素是否具有 required 属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8287353/

相关文章:

javascript - 获取元素左侧的像素 Javascript 似乎仅在稍微调整窗口大小时才起作用

python - 如何使用 Python 将字符串转换为类子属性

javascript - 如何设置选项文本 :selected in jquery

html - 在选择下拉列表中设置默认选定值 Vue.Js

html - CSS 列百分比无法按预期工作

javascript - 动态内容被抛出表格之外

c# - 如何使用 C# 在 Internet Explorer 中读取当前页面呈现的 HTML?

c++ - 在 C++ 中,可以在运行时设置/更改类属性 - 公共(public)、私有(private)或 protected 吗?

templates - 如何从函数类型中删除属性?

javascript - jQuery 选择框根据 url 选择选项