I this select dropdown on my page
use:
window.location.hash="someAnchor";
to jump to the anchor <a id="someAnchor" />
You can use animate
like this to scroll to selected element in animated fashion:
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery("#select1").change(function(){
var jump = jQuery("#select1").val();
var new_position = jQuery('#job'+jump).offset();
$('body, html').animate({scrollTop, jQuery('#job'+jump).offset().top})
return false;
});
}
</script>
This easy one workes for me :
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
function scrollTo(target){
var targetPosition = $(target).offset().top;
$('html,body').animate({ scrollTop: targetPosition}, 'slow');
}
</script>
Now you can use the onChange event to to execute the function:
<select name="dropdpown" size="1" onChange="scrollTo(this.value)">
<option value="#link">text</option>
</select>
If you provide a correct link like this everything works fine
<div id="link"> ...
It took me a while because I am not used to javascript, but finally found a short and easy solution that works.
Greetiing mz