autofocus for textfield.

0
while onloading of the page the input field has to get autofocused as in the scenario of the default mendix popup page.I achived it but the autofocus is shifitng to last feild.Provide any relevent Idea or answer if u have worked on it before. $(document).ready(function(){ $(".text3").ready(function(){ .$("input").trigger("focus");  }); }); the above pasted code is I am using in that text3 is the class name of my input field but it is not giving importance to class in this.
asked
1 answers
2

You are almost there. Trick is that you need to set the focus on the first child of your input element. Here is my working code, where ‘focusonme’ is the class to add to your input-element in StudioPro and you already found the location to put the code:

$(document).ready(function() {              //Wait for all dom-elements to be rendered
try{  
  let inputstextbox=$('.focusonme')[0].firstChild;  // find input-element of focusonme
  if (typeof inputstextbox !='undefined'){          // check if you have found one
    inputstextbox.focus();
  }
} catch (error) {}
});

Included error-handling to render unexpected results harmless.

answered