JQuery set focus on an input control with a name (not an id)

There is lots of documentation on how to set the focus to a control with an ID, however there is very little showing how to do this when your form controls only have a name tag, rather than id.

Make sure you have JQuery loaded further up the page than this script runs.

Here is how to do it!

 

<script type=”text/javascript”>

$(document).ready(function(){

$(“input[name=’inputControlNameHere’]”).focus();

});

</script>

One Reply to “JQuery set focus on an input control with a name (not an id)”

Leave a Reply