开发者

How do I enable all inputs when a certain select option is chosen?

I have some(more than 10) inputs in my HTML form. On initial state all this inputs are disabled by default. There is also select element which changes exact inputs disabled property while selection made on it based on its selected value. In other words select element contains options which indicates which input need to be enabled. Now I want to enable exact input based on selected option. How it c开发者_StackOverflowan be done?


Add a class to the 'exceptional' one, e.g. special:

<input ... class='special' />

Then enable all but this with:

$('input').not('.special').removeAttr('disabled');


$('select').change(function() {

   if ($(this).val() === 'whatever') {
      $(':input:not(.whatever)').removeAttr('disabled');
   }

});
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜