jquery select下拉框操作
程序员文章站
2022-07-13 12:22:30
...
<html>
<head>
<script type="text/javascript" src="/jquery/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#ss").change(function(){
var checkText=$("#ss").find("option:selected").text();
var checkValue=$("#ss").val();
alert(checkText);alert(checkValue);
$("#selectTest").empty();
$("<option value='1'>1xxx</option><option value='2'>2xxx</option>").appendTo(":input[name='selectTest']")//添加下拉框的
});
});
</script>
</head>
<body>
<div id="myDiv"><h2>通过 AJAX 改变文本</h2></div>
<button id="b01" type="button">改变内容</button>
<select id="selectTest" name="selectTest">
<option value="1">11</option>
<option value="2">22</option>
<option value="3">33</option>
<option value="4">44</option>
<option value="5">55</option>
<option value="6">66</option>
</select>
<select id="ss" name="ss">
<option value="5">5dd</option>
<option value="6">fd</option>
</select>
</body>
</html>