2012-03-07 187 views
0

我有一个选择不显示'默认'选项。它看起来像这样: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> 

有人可以解释为什么吗?

谢谢。

+0

什么CSS类'quality_score_member hideWhenResaleMLS'包含哪些内容? – 2012-03-07 11:12:31

+0

该类实际上不存在。 – George 2012-03-07 11:28:06

+0

你是对的,这是因为上课,但不知道为什么。 – George 2012-03-07 11:35:19

回答

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> 
1

我已经看到了这个错误,当有人正在开发一个网页和清新,看看更新了好几次。您的浏览器通常会显示您最后选择的任何选项。这包括如果您在先前选择的选项之上或之下添加选项。

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

+0

不,不,这不是一个问题。实际上,有几个不同的选项卡会使用此HTML,并且只有其中一个不显示第一个选项。 – George 2012-03-07 11:31:11

0

尝试使用属性SELECTED(或者,分别为selected='selected'或类似[upd])与OPTION

2

我可以看到这样做的唯一原因是你的CSS类

quality_score_member hideWhenResaleMLS 

定义display: nonevisibility: hidden,或其他一些元素隐藏CSS属性之一。

编辑:原来它是jQuery删除选项。嗯,这是其他的唯一可能的原因;)

+0

当我在Google Chrome的元素部分查看时,该元素仅排除在外。 – George 2012-03-07 11:42:52

+0

@George排除如何? – 2012-03-07 12:00:20

+0

只是没有出现。我发现它来自 $('。hideWhen $ {saleCategoryType}')。remove(); 在那里谢谢你 – George 2012-03-07 12:01:41