2013-07-11 126 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(); 
    });