Do this.
If your element is something like this..
<input type="text" id="mytext"/>
Your script would be
<script>
function setFocusToTextBox(){
document.getElementById("mytext").focus();
}
</script>
More Related Contents:
- How to focus on a form input text field on page load using jQuery?
- Can multiple HTML elements receive focus at the same time?
- CSS: Change parent on focus of child
- Set cursor at a length of 14 onfocus of a textbox
- How to scroll to an element in jQuery?
- Adding space between numbers
- How can I force input to uppercase in an ASP.NET textbox?
- trigger file upload dialog using javascript/jquery
- Double digit 30 seconds countdown
- Using HTML5/Canvas/JavaScript to take in-browser screenshots
- Way to ng-repeat defined number of times instead of repeating over array?
- innerText vs innerHTML vs label vs text vs textContent vs outerText
- Connecting to TCP Socket from browser using javascript
- Add a tooltip to a div
- How do I fix blurry text in my HTML5 canvas?
- File Upload without Form
- How to embed an autoplaying YouTube video in an iframe?
- React.js: Set innerHTML vs dangerouslySetInnerHTML
- Which is better: … or …
- Is innerHTML asynchronous?
- how to use json file in html code
- Browser back button handling
- Hiding a button in Javascript
- Change the style of :before and :after pseudo-elements? [duplicate]
- Anyone have a diff algorithm for rendered HTML? [closed]
- Change image in HTML page every few seconds
- Extract the text out of HTML string using JavaScript
- Drawing arrows on an HTML page to visualize semantic links between textual spans
- converting a javascript string to a html object [duplicate]
- How to pass parameters through iframe from parent html?