日期:2014-05-16 浏览次数:20377 次
<select id="s">
<option value="admin">admin</option>
</select>
<br />
<input id="chk" name="chk" type="checkbox" /><lable for="chk">许可追加",mote"</lable>
<script type="javascript">
$("#chk").unbind("change").bind("change",function(){
var str = $("#s").text();
if(this.checked){
if(!str.text(/\,mote$/i)){
str += ",mote";
}
}else{
if(str.text(/\,mote$/i)){
str = str.replace(/\,mote$/i,"");
}
}
$("#s>option:selected").text(str);
});
</script>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script language="javascript">
$(function(){
$(":checkbox").change(function(){
if($(this).is(":checked")){
$("#selectform").append('<option value=\"moto\">mote</option>');
}else{
$("#selectform").html('<option value=\"admin\">admin</option>');
}
});
})
</script>
<select id="selectform">
<option value="admin">admin</option>
</select>
<br/>
<input type="checkbox" id="box" />许可追加",mote"