I'm having some trouble using jquery on a select input in webkit browsers.
I've got a standard HTML select input populated with data retrieved from a database in php, like this:
<select id="select_menu">
foreach($all_sections as $key => $value) {
$menu_element = $options['menu_element_'.$key.''];
$menu_text = $options['menu_text_'.$key.''];
if ($menu_element == "1") {
echo '<option class="select_menu_link" value="#'.$key.'">'.$menu_text.'</option>';
}
}
</select>
Now, i wrote a simple script that fetches the value of each option and uses it to scroll to that specific element (using the jquery ScrollTo library).
<script>
$('.select_menu_link').click(function(){
var target_name = $(this).attr("value");
target_offset_top = $(target_name).offset().top;
target_position = target_offset_top - 100;
$('html,body').scrollTo( {top: target_position, left:'0'}, 450 );
});
</script>
This code works perfectly on Firefox and IE: when the user clicks over an option of the select input, the website scrolls to that point. However, it has no results on Chrome and Opera. Do you have any idea why? Any input (no pun intended) would be really appreciated!