在html中设置选项的默认值

时间:2016-11-22 12:17:40

标签: html

我将以下html代码作为页面加载时的默认值。但它没有反映在页面上。

<div class="col-sm-6 col-xs-12 col-md-6 col-lg-6">
    <label for="headoffice" class="col-sm-6 col-xs-7 col-md-4 col-lg-4 control-label">Head Office Member<sup class="text-red">*</sup></label>
    <div class="col-sm-6 col-xs-12 col-md-8 col-lg-8">                  
        <select class="multi-select" id="headoffice" name="headoffice" data-placeholder="Head Office Member">
            <option value=""></option>
            <option value="No" selected="selected">No</option>
            <option value="Yes">Yes</option> 
        </select>
    </div>
</div> 

1 个答案:

答案 0 :(得分:0)

在给定的HTML代码中,您已为选项指定了 selected =“selected”。您需要在“是”选项中给出如下选项。

<div class="col-sm-6 col-xs-12 col-md-6 col-lg-6">
    <label for="headoffice" class="col-sm-6 col-xs-7 col-md-4 col-lg-4 control-label">Head Office Member<sup class="text-red">*</sup></label>
    <div class="col-sm-6 col-xs-12 col-md-8 col-lg-8">                  
        <select class="multi-select" id="headoffice" name="headoffice" data-placeholder="Head Office Member">
            <option value=""></option>
            <option value="No" >No</option>
            <option value="Yes" selected="selected">Yes</option> 
        </select>
    </div>
</div>