HTML选择下拉列表 [英] HTML select dropdown list
问题描述
我想要使用select,option标签下拉列表......但是当它第一次出现时,我希望它有一个信息,例如请选择一个名称,然后用户单击下拉列表并从可用的选项中进行选择...我尝试将请选择一个名称作为选项,但用户将能够选择此...这不是我想要的。我需要使用JavaScript来获得这个功能吗?或者我需要做什么?
I want to have a drop down list using the select, option tag... but when it first appear I want it to have an information, such as "Please select a name" then the user clicks on the drop down list and selects from the available option... I tried to made the "Please select a name" as an option, but then the user will be able to select this... which is not what I want. Do I need to use javascript to have this feature or what do I need to do?
如果有jQuery的方式来做到这一点, p>
If there'a jquery way to do this, this would be much helpful
推荐答案
有
Have <option value="">- Please select a name -</option>
as the first option and use JavaScript (and backend validation) to ensure the user has selected something other than an empty value.
这篇关于HTML选择下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!