在从下拉列表中选择一个选项之前,我需要将“none”选项设为默认值。我的代码如下。
<select name="SelectFlow" id="Flow"> </select>
<script>
var select = '';
for (i=0;i<=100;i++){
select += '<option val=' + i + '>' + i + '</option>';
}
$('#Flow').html(select);
</script>
答案 0 :(得分:-1)
在您的javascript代码中添加一行:
<select name="SelectFlow" id="Flow"> </select>
<script>
var select = '<option selected="selected">None</option>';
for (i=0;i<=100;i++){
select += '<option val=' + i + '>' + i + '</option>';
}
$('#Flow').html(select);
</script>
请参阅:How can I set the default value for an HTML <select> element?