选择中的禁用选项 [英] Disable option in select
本文介绍了选择中的禁用选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个选择:
<select>
<option class="1">1st</option>
<option class="2">other1</option>
<option class="2">other2</option>
<option class="1">2st</option>
<option class="2">other1</option>
<option class="2">other2</option>
</select>
如何禁用类"1"的选项?
How can I disable the options with class "1"?
推荐答案
<select>
<option class="1">1st</option>
<option class="2">other1</option>
<option class="2">other2</option>
<option class="1">2st</option>
<option class="2">other1</option>
<option class="2">other2</option>
</select>
<script>
$(function(){
$('select').find('option.1').attr('disabled', 'disabled');
});
</script>
注意:您的班级名称未遵循约定
Note: Your class names are not following convention
命名规则:
- 必须以字母A-Z或a-z开头
- 后面可以跟:字母(A-Za-z),数字(0-9),连字符(-"), 和下划线("_")
- 在HTML中,所有值都不区分大小写
- Must begin with a letter A-Z or a-z
- Can be followed by: letters (A-Za-z), digits (0-9), hyphens ("-"), and underscores ("_")
- In HTML, all values are case-insensitive
这篇关于选择中的禁用选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文