1
私は 'colors'-dropdownから選択できる素敵なスクリプトを使用しています。最初のオプションを選択すると、別の「数字」ドロップダウンが配置されました。しかし今、問題:この「数字」ドロップダウンで何かを選択すると、すべての選択メニューが消滅します。私はそれを維持して独自のハイパーリンクを与えたい。私のコード:どちらかselect
が変更されたときにjquery showドロップダウンからのドロップダウン
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Select Box</title>
<script type="text/javascript" src="http://code.jquery.com/jquery.min.js"> </script>
<script type="text/javascript">
$(document).ready(function(){
$("select").change(function(){
$(this).find("option:selected").each(function(){
if($(this).attr("value")=="red"){
$(".box").not(".red").hide();
$(".red").show();
}
else if($(this).attr("value")=="green"){
$(".box").not(".green").hide();
$(".green").show();
}
else if($(this).attr("value")=="blue"){
$(".box").not(".blue").hide();
$(".blue").show();
}
else{
$(".box").hide();
}
});
}).change();
});
</script>
</head>
<body>
<div>
<select>
<option>Choose Color</option>
<option value="red">Red</option>
<option value="green">Green</option>
<option value="blue">Blue</option>
</select>
</div>
<div class="red box" style="margin-top:10px;"><select>
<option>Choose number</option>
<option>1</option>
<option>2</option>
<option>3</option>
</select></div>
<div class="green box">You have selected <strong>green option</strong> so i am here</div>
<div class="blue box">You have selected <strong>blue option</strong> so i am here</div>
</body>
</html>
おかげで、素晴らしい作品。 –
@Jandeあなたは大歓迎です! – brso05