$("#select_id").append(""); //In Insert an option in front $("#select_id option:last").remove(); //Remove the option with the largest index value $("#select_id option[index='0']"). remove();//Delete the option with index value 0 $("#select_id option[value='3']").remove(); //Delete option with index value 3 $(" #select_id option[text='4']").remove(); //Delete option with text value 4
Clear select:
$("#ddlregtype " ).empty();
The work needs to get the values in the two forms. As shown in the picture:
How to get the value added from the left selection box to the right selection box? I thought about using web page special effects to get it, and the more popular jquery was used here. The js code is as follows:
//Get all attributes Value var item = $("#select1").val(); $(function(){ $('#select1').each( //Get all values of select1 function( ){ $('button').click(function(){ alert($('#select2').val()); //Get the select1 value in select2 }); }); })
It is worth noting that it cannot be written directly as
$(function(){ $('#select2').each( //Get all values of select1 , because as mentioned above, options are added from the left to the right, jquery does not actually pass the value from the left to the right. function(){ $('button').click(function(){ alert($(this).val()); //Get the select1 value in select2 }); }); })
//Bind ClassLevel1 click event $("#ClassLevel1").change(function () { var id = $("#ClassLevel1").val(); var level2 = $("#ClassLevel2"); level2.empty(); $("#ClassLevel3").hide(); $.ajax({ url: "./askCommon.ashx?action=getclasslevel&pid=" id, data: { "type": "ajax" }, datatype: "json", type: "get", success: function (data) { var json = eval_r(data); for (var ind in json) { level2.append($("")); }
} }); })
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn