jquery 操作 可多选的select下拉框 以下为代码:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE> New Document </TITLE> <META NAME="Generator" CONTENT="EditPlus"> <META NAME="Author" CONTENT=""> <META NAME="Keywords" CONTENT=""> <script src="jquery.js" LANGUAGE="JavaScript"></script> <SCRIPT LANGUAGE="JavaScript"> $(document).ready(function(){ //添加 $("#add").click(function() { var dept; var flag=1; var depts = $("#deptId option[selected]"); var addDepts = $("#addDept option"); if(addDepts.length==0) { $.each(depts,function(){ dept = this; $("#addDept").append("<option value='"+dept.value+"'>"+dept.text+"</option>"); }); }else { $.each(depts,function(){ flag=0; dept = this; $.each(addDepts,function(){ if(dept.value==this.value) { flag=1; false; } }); if(flag==0) { $("#addDept").append("<option value='"+dept.value+"'>"+dept.text+"</option>") } }); } }); }); </SCRIPT> </HEAD> <BODY> <select name="select" style="width:150px" id="deptId" size="10" multiple="multiple"> <option value="1">ih99</option> <option value="2">ih99.com</option> <option value="3">www.ih99.com</option> </select> <button id="add">>></button> <select name="select2" style="width:150px" id="addDept" multiple="multiple" size="10"> </select> </BODY> </HTML>
?