내가하려는 것은 모든 애완 동물에서 값이 변경되면 품종 드롭 다운을 활성화하고 사용자가 모든 애완 동물을 다시 클릭하면 품종 드롭 다운이 다시 비활성화됩니다. 다음은 jsfiddle http://jsfiddle.net/2yWeN/입니다.
<form id="filter" class="filter" action="http://dev/petlist/public/site/index" accept-charset="utf-8" method="post">
<select name="petsDropDown" id="form_petsDropDown">
<option value="allPets">All Pets</option>
<option value="barnyard">Barnyard</option>
<option value="bird">Bird</option>
<option value="cat">Cats</option>
<option value="dog">Dogs</option>
<option value="horse">Horse</option>
<option value="pig">Pigs</option>
<option value="smallfurry">Smallfurry</option>
</select>
<select name="breedDropDown" id="form_breedDropDown">
<option value="select_breed">Select Breed</option>
</select>
</form>
$(function(){
if($("#form_petsDropDown option:first").attr('selected','selected')){
$('#form_breedDropDown').prop('disabled', 'disabled');
}
$('#form_petsDropDown').change(function() {
$('#form_breedDropDown').prop('disabled', false);
if ($('#form_petsDropDown allPets:selected').text() == 'All Pets'){
console.log('worked');
$('#form_breedDropDown').attr('disabled', 'disabled');
}
});
});
시험:
$('#form_petsDropDown').change(function(){
$('#form_breedDropDown').prop('disabled',($(this).val()=='allPets'));
}).change();
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다