2013-07-11 82 views
2

我有一個下拉,應該改變我的網頁功能,但顯然不工作。一旦用戶選擇並在行業中更新地圖,並且應該更新下面的圖例,我會在下拉選擇中找到地圖。圖例不更新下拉選擇變化

請指出我做錯了什麼。

謝謝

JS

$("#lstMap1Occ").change(function() { 
     var index = $(this).children(":selected").index(); 
     $("#legend").children().hide().eq(index).show(); 
    }); 

這裏是下拉(是的,有一個結束選擇標籤IST只是沒有粘貼在一些奇怪的原因)

<select id="lstMap1Occ"> 
    <option value="1">Engineers </option> 
    <option value="2">Chemical Engineers</option> 
</select> 

HTML

<div class="legend"> 
<div class="engineers"> 
    <ul> 
     <li style="background-color:rgb(254,240,217);">0-345</li> 
     <li style="background-color:rgb(253,212,158);">346-503</li> 
     <li style="background-color:rgb(253,187,132);">504-1240</li> 
     <li style="background-color:rgb(252,141,89);">1241-1679</li> 
     <li style="background-color:rgb(239,101,72);">1680-2625</li> 
     <li style="background-color:rgb(215,48,31);">2627-4789</li> 
    </ul> 
</div> 
<div class="chemical"> 
    <ul> 
     <li style="background-color:rgb(254,240,217);">0-13</li> 
     <li style="background-color:rgb(253,212,158);">14-24</li> 
     <li style="background-color:rgb(253,187,132);">25-37</li> 
     <li style="background-color:rgb(252,141,89);">38-56</li> 
     <li style="background-color:rgb(239,101,72);">57-112</li> 
     <li style="background-color:rgb(215,48,31);">113-168</li> 
    </ul> 
</div> 

+0

第一個問題是$( 「#傳說」)應該是$( ​​「傳奇」),但這不是它的全部。 –

+1

你的傳奇還有結尾嗎? –

+1

實際上,我一直在看這個這麼長時間,我從來沒有把「#」改成「」。一旦我做到了,它的工作和我的意圖。感謝您指出Nathan –

回答

1

.legend不#legend http://jsfiddle.net/fy6hf/1/

$("#lstMap1Occ").change(function() { 
     var index = $(this).children(":selected").index(); 
     $(".legend").children().hide().eq(index).show(); 
    });