Get the value from the drop-down box and set the default value:
##
<select id="test"> <option value="1">选项一<option> <option value="2">选项一<option> ... <option value="n">选项N<option> </select>
$('#test option:first').val();
$('#test option:last').val();
$('#test option:eq(1)').val();
$('#test').val(); $('#test option:selected').val();
$(‘#test’).attr(‘value’,’2’);
$('#test option:last').attr('selected','selected'); $("#test").attr('value' , $('#test option:last').val()); $("#test").attr('value' , $('#test option').eq($('#test option').length - 1).val());
$('#test option').length;
$("#test").append("<option value='n+1'>第N+1项</option>"); $("<option value='n+1'>第N+1项</option>").appendTo("#test");
$('#test option:selected').remove();
$('#test option:first').remove();、
$('#test option').each(function(){ if( $(this).val() == '5'){ $(this).remove(); } }); $('#test option[value=5]').remove();
$('#test optgroup:eq(0)').attr('label');
$('#test optgroup:eq(1) : option:eq(0)').val();
$("#arrangeClass").find("option[value="+reim.classId+"]").prop("selected",true);
bootstrap introductory tutorial
The above is the detailed content of How to set default value for bootstrap drop-down list. For more information, please follow other related articles on the PHP Chinese website!