I have a relatively simple issue I'm trying to resolve and can't seem to find anything about it.
I am working on existing product, after an error modal is closed I need to focus on a given form field, which at this point I will have stored in a variable.
Currently this works:
$("input[field='number']").focus();
I've simplified the variable names. No I have a variable as below;
myField = 'number'
But my attempts to focus on this are failing, I've tried:
$("input[field=myField]").focus();
$("input[field='myField']").focus();
As I said I've had a look around but sadly cannot find what I need. Any help would be greatly appreciated.
Thanks
You are using a variable name instead of its contents.
Try this
$("input[field='" + myField + "']").focus();
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