Here I created a sample to help me be understood, http://www.jsfiddle.net/BLvsF/
I want the item-'a6' to be scrolled into the visible select box, how can I make it? I'd like to use jquery to do same as
$(document).ready(function() {
$('#btn').click(function() {
document.getElementById('a6').scrollIntoView();
});
});
but, how to implement the same using jQuery?
I tried using .get(0).scrollIntoView(). but still not applicable.
$(document).ready(function() {
$('#btn').click(function() {
$('#a> option:selected').clone(false).appendTo('#b').get(0).scrollIntoView();
});
});
http://www.jsfiddle.net/CYQfD/
Thanks, Elaine
just replace the button handler with this line of code, and you are done.
$('#a').val('a6').scrollIntoView();
This works fine...
$(document).ready(function() {
$('#btn').click(function() {
//document.getElementById('a6').scrollIntoView();
var target = $("#b");
$('#a> option:selected').clone(false).appendTo(target);
target.get(0).selectedIndex = target.get(0).options.length - 1;
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With