选择元素是否具有必需的属性?

Does the select element have the required attribute?(选择元素是否具有必需的属性?)
本文介绍了选择元素是否具有必需的属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

select 元素是否具有 required 属性?

Does the select element have the required attribute?

推荐答案

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

Yes you can use required attribute in HTML5. But remember, first value should be empty.

<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

这篇关于选择元素是否具有必需的属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

Select OK button from N#39;th modal opened in testcafe(从 testcafe 中打开的第 N 个模式中选择 OK 按钮)
How to click a specified li for an autocomplete ul with Selenium IDE?(如何使用 Selenium IDE 为自动完成 ul 单击指定的 li?)
Test automation html element selectors. Element ID or DataAttribute(测试自动化 html 元素选择器.元素 ID 或 DataAttribute)
navigator.geolocation.getCurrentPosition not allowed on quot;file:///C:/quot; based access(“file:///C:/上不允许 navigator.geolocation.getCurrentPosition基于访问)
Geolocation not working on Safari 5.x on Windows 7/XP(地理定位在 Windows 7/XP 上的 Safari 5.x 上不起作用)
Request location coordinates after user has blocked access in javascript(用户在 javascript 中阻止访问后请求位置坐标)