How to implement .scrollTo plugin in a dropdown list? When I choose one option from a dropdown list, it gets the value and shows specific div but how to make this div scroll up instantly after the user chooses the option? I used this plugin already with links a href and this is easy but I have no idea how to implement it with dropdowns.
Here is the html:
<select id="miasto">
<option value="v1">opt1</option>
<option value="v2">opt1</option>
<option value="v3">opt1</option>
</select>
Divs to be be displayed after selecting an option:
<div id="v1" class="schowaj" style="display:none">div1 content</div>
<div id="v2" class="schowaj" style="display:none">div2 content</div>
<div id="v3" class="schowaj" style="display:none">div3 content</div>
jQuery:
$(function(){
$('#miasto').change(function(){
var divToShow = $('#'+$(this).val());
$('.schowaj').not(divToShow).hide('slow');
divToShow.show('slow');
});
});
Wrap your code into select change event listener: