admin管理员组文章数量:1310431
I have a drop down html form and would like to display the disabled=disabled
element (view the edit below)
At first initial glance, the form skips the disabled
element and displays "option 1".
<select>
<option disabled='disabled'>Title</option>
<option>Option 1</option>
<option>Option 2</option>
<option>Option 3</option>
</select>
Is this possible with just html
or css
?
If not then how about jQuery
or javascript
?
Edit
Would like the form to look like this
Currently it looks like
I have a drop down html form and would like to display the disabled=disabled
element (view the edit below)
At first initial glance, the form skips the disabled
element and displays "option 1".
<select>
<option disabled='disabled'>Title</option>
<option>Option 1</option>
<option>Option 2</option>
<option>Option 3</option>
</select>
Is this possible with just html
or css
?
If not then how about jQuery
or javascript
?
Edit
Would like the form to look like this
Currently it looks like
- @OneTrickPony can you elaborate please – s_p Commented Jan 31, 2013 at 16:38
- You have posted the right answer as your question. – techfoobar Commented Jan 31, 2013 at 16:38
- @t q: what's the question here exactly? You want to disable a certain option with javascript? – nice ass Commented Jan 31, 2013 at 16:40
-
@OneTrickPony When the user views the form I would like them to se the
disabled
option, so in my case they would see "Visible Title" rather than 'Option 1' as their first choice. But because it is disabled they would NOT be able to click this element. – s_p Commented Jan 31, 2013 at 16:44 - 1 Disabled options are displayed, but greyed out and unselectable. – Barmar Commented Jan 31, 2013 at 16:46
1 Answer
Reset to default 9Add selected="selected"
to your first option.
<select>
<option selected="selected" disabled='disabled'>Visible Title</option>
<option>Option 1</option>
<option>Option 2</option>
<option>Option 3</option>
</select>
jsFiddle example
本文标签: javascriptdisplay disabled option elementhtml drop down formStack Overflow
版权声明:本文标题:javascript - display disabled option element - html drop down form - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741833320a2400065.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论