<script>
$('#Select_Font').attr('disabled', 'true');
$('#Enter_Text').attr('disabled', 'true');
$('.dropdownstyle').change(function(){
$(".dropdownstyle option:selected").text();
if($(this).attr('value').match(/Custom$/))
{
$('#Select_Font').attr('disabled', 'false');
$('#Enter_Text').attr('disabled', 'false');
} else if($(this).attr('value').match(/no Thanks$/))
{
$('#Select_Font').attr('disabled', 'true');
$('#Enter_Text').attr('disabled', 'true');
}
});
</script>
<table>
<tbody>
<tr>
<td>
<span>Select type</span>
</td>
<td>
<select class="dropdownstyle">
<option value="No Thanks">No Thanks</option>
<option value="Custom lid (200)">Custom lid (200)</option>
</select>
</td>
</tr>
<tr>
<td>
<span>Select font</span>
</td>
<td>
<select id="Select_Font">
<option value="Arial">Arial</option>
<option value="georgia">georgia</option>
</select>
</td>
</tr>
<tr>
<td>
<span>enter text</span>
</td>
<td>
<input type="text" id="Enter_Text">
</td>
</tr>
</tbody>
</table>
在上面的代码最初我希望字体下拉和文本框禁用,但选择自定义窗体第一个下拉我希望字体下拉和文本框启用。 我不确定我要出错的地方,所以应该做些什么才能使它工作。如何启用或禁用选择其他下拉菜单上的下拉菜单或文本框?
这是正确的$(this).attr('value')。match(/ Custom $ /)或者其他方式是更好的检查? – 2013-03-08 19:07:58
查看更新的答案与工作小提琴... – Anujith 2013-03-08 19:09:09
其工作谢谢... – 2013-03-08 19:18:20