Hi Can anybody tell me How to move the cursor into a input text box by clicking on html button ?
            Asked
            
        
        
            Active
            
        
            Viewed 2.9k times
        
    5
            
            
        - 
                    Answered here: http://stackoverflow.com/questions/15859113/focus-not-working by @justin-warkentin – samuelkobe Apr 07 '15 at 09:00
3 Answers
2
            
            
        HTML:
<input type="text" id="my_textbox" value="My Text" />
<button id="my_button">Focus</button>
JS:
document.getElementById('my_button').onclick = function() {
    document.getElementById('my_textbox').focus();
};
Example:
 
    
    
        Geo
        
- 12,666
- 4
- 40
- 55
1
            
            
        You can just do it by using jQuery as follows:
Include jquery in HTML HEAD section then
$( "#button" ).click(function() {
$( "#targetinput" ).focus();
});
Or without jquery you can do it using
getElementByID("targetinput").focus();
 
    
    
        عثمان غني
        
- 2,786
- 4
- 52
- 79
 
     
    