禁用下拉列表并根据单选按钮为其标签着色

时间:2014-04-07 16:49:40

标签: jquery forms colors

我有以下内容,由于某种原因,我不能让下拉列表禁用或标签更改颜色。基本上唯一有效的是禁用文本框。

$(document).ready(function() {
 $('input:radio[name=Event-Location]').click(function() {
    var checkval = $(this).val();
    $('#Reservation-Style').prop('disabled', !(checkval == 'City1'));
    $('label[for=Reservation-Style]').css({color:'red'}, !(checkval == 'City1'));
    $('label[for=Reservation-Style]').css({color:'black'}, !(checkval == 'City2'));
    $('#Permits-Needed').prop('disabled', !(checkval === 'City1'));  
    $('#Permits-Needed').prop('enabled', !(checkval === 'City2'));
 });

});

html看起来像:

<div id="Event-Location" class="formelement">
  <input type="radio" name="Event-Location" value="City1" />City 1 Campus<br />
  <input type="radio" name="Event-Location" value="City2" />City 2 Campus
</div>

<h3>City 2 Events Only</h3>

<label class="uni-form-text-label" for="Reservation-Style">Reservation Style:</label>
<select name="Reservation-Style" >
  <option>- Style -</option>
  <option value="Permits">Individual Permits</option>
  <option value="Cordon">Cordoned Parking Area</option>
</select>

<label for="Number-Permits-Needed">How Many Permits are needed? </label>
<input id="Number-Permits-Needed" class="text" type="text" name="Number-Permits-Needed" size="15">

0 个答案:

没有答案