javascript - Focus on a form field with a variable -


i have relatively simple issue i'm trying resolve , can't seem find it.

i working on existing product, after error modal closed need focus on given form field, @ point have stored in variable.

currently works:

$("input[field='number']").focus(); 

i've simplified variable names. no have variable below;

myfield = 'number'

but attempts focus on failing, i've tried:

$("input[field=myfield]").focus(); $("input[field='myfield']").focus(); 

as said i've had around sadly cannot find need. appreciated.

thanks

you using variable name instead of contents.

try this

$("input[field='" + myfield + "']").focus();  

Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -