html select不显示默认选项

时间:2012-03-07 11:11:03

标签: html

我有一个不显示'默认'选项的选项。它看起来像这样:

<select id="sortBy" name="sortBy" onchange="if(guestLightbox()) {sortPropertyBy(this.value);}">
<option class="quality_score_member hideWhenResaleMLS" value="quality_score_member-desc">Default</option>
<option class="auction_date hideWhenForeclosures hideWhenPreForeclosures hideWhenResaleMLS hideWhenFSBOOrRentalOrRTO" value="auction_date">Auction Date</option>
<option class="home_score-desc" value="home_score-desc">SmartZip HomeScore</option>
<option class="investor_score-desc" value="investor_score-desc">SmartZip InvestorScore</option>
<option class="amount" value="amount">Price (low to high)</option>
<option class="amount-desc" value="amount-desc">Price (high to low)</option>
<option class="living_area_square_feet" value="living_area_square_feet">Square Feet (low to high)</option>
<option class="living_area_square_feet-desc" value="living_area_square_feet-desc">Square Feet (high to low)</option>
<option class="scrape_date-desc" value="scrape_date-desc">Most Recent</option>
<option class="sale_type" value="sale_type">Sale Type</option>
<option class="property_record_type" value="property_record_type">Property Type</option>
</select>

有人可以解释原因吗?

感谢。

4 个答案:

答案 0 :(得分:2)

我能看到的唯一原因是你的一个CSS类

quality_score_member hideWhenResaleMLS

定义display: nonevisibility: hidden或其他隐藏元素的CSS属性。

  

编辑:结果是jQuery删除了该选项。嗯,这是唯一可能的原因;)

答案 1 :(得分:1)

当有人正在开发页面并刷新以查看更新时,我已经看过很多次此错误。您的浏览器通常会显示您最后选择的任何选项。这包括如果您在先前选择的选项之上或之下添加选项。

尝试从头开始再次访问该页面(不使用刷新)并告诉我们是否能解决您的问题。

答案 2 :(得分:0)

Jsfiddle

上工作
<select id="sortBy" name="sortBy" onchange="if(guestLightbox()) {sortPropertyBy(this.value);}">
    <option class="quality_score_member hideWhenResaleMLS" value="quality_score_member-desc">Default</option>
    <option class="auction_date hideWhenForeclosures hideWhenPreForeclosures hideWhenResaleMLS hideWhenFSBOOrRentalOrRTO" value="auction_date">Auction Date</option>
    <option class="home_score-desc" value="home_score-desc">SmartZip HomeScore</option>
    <option class="investor_score-desc" value="investor_score-desc">SmartZip InvestorScore</option>
    <option class="amount" value="amount">Price (low to high)</option>
    <option class="amount-desc" value="amount-desc">Price (high to low)</option>
    <option class="living_area_square_feet" value="living_area_square_feet">Square Feet (low to high)</option>
    <option class="living_area_square_feet-desc" value="living_area_square_feet-desc">Square Feet (high to low)</option>
    <option class="scrape_date-desc" value="scrape_date-desc">Most Recent</option>
    <option class="sale_type" value="sale_type">Sale Type</option>
    <option class="property_record_type" value="property_record_type">Property Type</option>
</select>

答案 3 :(得分:0)

使用SELECTED尝试属性selected='selected'(或OPTION或类似[upd])。