How to set cursor to input box in Javascript?
问题 document.getElementById(frmObj.id).value=""; document.getElementById(frmObj.id).autofocus; document.getElementById("errorMsg").innerHTML = "Only numeric value is allowed"; In the above code the value of the form object is perfectly setting to "" but there is no cursor in the text box. I want a cursor to be there. focus() only focuses that input box but does not actually set the cursor. 回答1: In JavaScript first focus on the control and then select the control to display the cursor on texbox...