Reputation: 393
The scrollTop
function in jQuery for select list is working only in Firefox. In other browsers it's not working.
For example
<select id="mySelect">
<option value="1">1</option>
<option value="2">2</option>
...
<option value="100">100</option>
</select>
$('#mySelect').click(function(){
$(this).scrollTop(150);
});
Does anybody know how to resolve this problem so it works across all browsers?
Upvotes: 1
Views: 738
Reputation: 69905
Try this
$('#mySelect').click(function(){
var $options = $(this).find("option");
$options.eq(($options.length)/2)[0].selected = true;
});
Upvotes: 1
Reputation: 6260
It could be that the select box doesn't support a click event in some browser? I'm assuming you want the browser to scroll to the that section of the page and then let them make a selection. You could try a change
or focus
event instead.
Upvotes: 0