开发者

How do I preselect in a drop down list box? [duplicate]

开发者 https://www.devze.com 2023-02-25 07:02 出处:网络
This question already has answers here: How can I set the default value for an HTML <select> element?
This question already has answers here: How can I set the default value for an HTML <select> element? (34 answers) Closed 3 years ago.

I am trying to preselect like this:

<option selected="yes" value="test1" &g开发者_开发技巧t;test1</option

But I get a message in VS2010 saying "Validation HTML5: The value permitted for this attribute do not include 'yes'.

Am I doing something wrong. I thought the way to preselect was as above.


it should be selected="selected"

<option selected="selected" value="test1" >test1</option>


Selected attribute only contain selected value, like this:

<option selected="selected" value="test1">test1</option>


<option selected="selected">test1</option>

Would be the correct way to do it, AFAIK.


try selected="selected" or you can just leave the selected without any value like <option selected>test1</option>

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号