我實在是苦手於 jquery 每次都在找基礎與法跟屬性,哪裡有最最最基礎的 jquery 教學,我發誓我一定會乖乖全部啃完。
算了,呆呆去書店找一下好了,網路資料太多,好難精準搜尋。
如果有更好的寫法,也歡迎與我交流~
it looks like this:
<script type="text/javascript">
$("#SELECT1").change(function(){
$("#SELECT2").removeAttr('selected').find('option:first').attr('selected', 'selected');
$("#SELECT3").removeAttr('selected').find('option:first').attr('selected', 'selected');
});
$("#SELECT2").change(function(){
$("#SELECT1").removeAttr('selected').find('option:first').attr('selected', 'selected');
$("#SELECT3").removeAttr('selected').find('option:first').attr('selected', 'selected');
});
$("#SELECT3").change(function(){
$("#SELECT1").removeAttr('selected').find('option:first').attr('selected', 'selected');
$("#SELECT2").removeAttr('selected').find('option:first').attr('selected', 'selected');
});
</script>
<p>
SELECT1:
<select id="SELECT1" name="SELECT1">
<option value="" selected="selected">---------</option>
<option value="value1">SELECT1 ITEM1</option>
<option value="value2">SELECT1 ITEM2</option>
<option value="value3">SELECT1 ITEM3</option>
<option value="value4">SELECT1 ITEM4</option>
<option value="value5">SELECT1 ITEM5</option>
</select>
</p>
<p>
SELECT2:
<select id="SELECT2" name="SELECT2">
<option value="" selected="selected">---------</option>
<option value="value1">SELECT2 ITEM1</option>
<option value="value2">SELECT2 ITEM2</option>
<option value="value3">SELECT2 ITEM3</option>
<option value="value4">SELECT2 ITEM4</option>
<option value="value5">SELECT2 ITEM5</option>
</select>
</p>
<p>
SELECT3:
<select id="SELECT3" name="SELECT3">
<option value="" selected="selected">---------</option>
<option value="value1">SELECT3 ITEM1</option>
<option value="value2">SELECT3 ITEM2</option>
<option value="value3">SELECT3 ITEM3</option>
<option value="value4">SELECT3 ITEM4</option>
<option value="value5">SELECT4 ITEM5</option>
</select>
</p>
$("#SELECT1").change(function(){
$("#SELECT2").removeAttr('selected').find('option:first').attr('selected', 'selected');
$("#SELECT3").removeAttr('selected').find('option:first').attr('selected', 'selected');
});
$("#SELECT2").change(function(){
$("#SELECT1").removeAttr('selected').find('option:first').attr('selected', 'selected');
$("#SELECT3").removeAttr('selected').find('option:first').attr('selected', 'selected');
});
$("#SELECT3").change(function(){
$("#SELECT1").removeAttr('selected').find('option:first').attr('selected', 'selected');
$("#SELECT2").removeAttr('selected').find('option:first').attr('selected', 'selected');
});
</script>
<p>
SELECT1:
<select id="SELECT1" name="SELECT1">
<option value="" selected="selected">---------</option>
<option value="value1">SELECT1 ITEM1</option>
<option value="value2">SELECT1 ITEM2</option>
<option value="value3">SELECT1 ITEM3</option>
<option value="value4">SELECT1 ITEM4</option>
<option value="value5">SELECT1 ITEM5</option>
</select>
</p>
<p>
SELECT2:
<select id="SELECT2" name="SELECT2">
<option value="" selected="selected">---------</option>
<option value="value1">SELECT2 ITEM1</option>
<option value="value2">SELECT2 ITEM2</option>
<option value="value3">SELECT2 ITEM3</option>
<option value="value4">SELECT2 ITEM4</option>
<option value="value5">SELECT2 ITEM5</option>
</select>
</p>
<p>
SELECT3:
<select id="SELECT3" name="SELECT3">
<option value="" selected="selected">---------</option>
<option value="value1">SELECT3 ITEM1</option>
<option value="value2">SELECT3 ITEM2</option>
<option value="value3">SELECT3 ITEM3</option>
<option value="value4">SELECT3 ITEM4</option>
<option value="value5">SELECT4 ITEM5</option>
</select>
</p>
0 留言