I have used jQuery Form Wizard and create a method for navigate to other input
in some form
.
function goto(id_step, id_input)
{
$('#demoForm').formwizard('show', id_step);
//unfocus first input
$("#demoForm").formwizard({
focusFirstInput : false
});
$('#'+id_input).focus();
}
goto('info', 'res_umur');
The function is ok, but the focus method doesn't scroll to focused input
element. Anyone know how to make it scroll?
Use scrollIntoView
$('#'+id_input)[0].scrollIntoView();
Modify your code:
function goto(id_step, id_input)
{
$('#demoForm').formwizard('show', id_step);
//unfocus first input
$("#demoForm").formwizard({
focusFirstInput : false
});
$('#'+id_input).focus();
$('#'+id_input)[0].scrollIntoView();
}
goto('info', 'res_umur');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.