更新問題:現在我可以讓白色襯衫工作,但不是黃色。我可以在白色的小med-lrg之間切換,但換到黃色仍然只會在白色襯衫大小之間變化。我已經凝結代碼,只顯示小小白和小黃如果選中單選按鈕並選擇了值,jquery
<select class="color">
<option value="white">White</option>
<option value="yellow">Yellow</option>
</select>
<input type="radio" class="size" name="size" value="small">Small
<input type="radio" class="size" name="size" value="medium" checked>Medium
<input type="radio" class="size" name="size" value="large">Large
和JS:
$('.size').click(function() {
shirtButtons.hide();
if($('.color').val() == 'white' || $('.size:checked').val() == 'small'){
shirtButtons.hide();
$('.white-small').show();
}else if($('.color').val() == 'yellow' || $('.size:checked').val() == 'medium'){
shirtButtons.hide();
$('.yellow-medium').show();
}
});
$('.color').change(function() {
shirtButtons.hide();
if($('.color').val() == 'white' || $('.size:checked').val() == 'small'){
shirtButtons.hide();
$('.white-small').show();
}else if($('.color').val() == 'yellow' || $('.size:checked').val() == 'small'){
shirtButtons.hide();
$('.yellow-small').show();
}
});
你忘了js嗎? –
對不起!添加! – Astarkey
@Astarkey什麼是shirtButtons? – Pavlo