2012-03-07 179 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