开发者

JQuery dropdown works on Firefox but not on Google Chrome

First the code might suck as I'm new with JQuery. I have this html:

<select name="numberItems" id="id_numberItems"> 
<option value="1" selected="selected">1</option> 
<option value="2">2</option> 
<option value="3">3</option> 
<option value="4">4</option> 
<option value="5">5</option> 
</select>
<fieldset class="dropdownList"> 
     [...]
</fieldset>
<fieldset class="dropdownList"> 
     [...]
</fieldset>  <!-- This fieldset is repeated 5 times -->

This is my Jquery code:

// Dropdown
function dropDown(val) {
    $('.dropdownList').hid开发者_开发知识库e();
    $('.dropdownList:lt(' + val + ')').show();
}

$("#id_numberItems").click(function() { dropDown($('#id_numberItems').val()) });

This dropDown thing is working on Firefox, but not in Google Chrome ¿why? Thanks


Attach your dropDown-function to the change-event of your dropdown and it should work the way you want it (or as my crystal ball suggests me...)

$("#id_numberItems").change(function() { dropDown($('#id_numberItems').val()) });

example on jsbin.com

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜