2015-01-20 2 views

답변

1

당신은 사용할 수 있습니다 HTMLInputElement.select()

$('#my-input').on('focus', function(){ 
 
    this.select(); 
 
}); 
 

 
$('#clickbutton').click(function(){ 
 
    $('#my-input')[0].focus(); 
 
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 

 
<input id="my-input" value="Select me on click"> 
 

 
<button id="clickbutton" value="Focus input and select" >Focus input and select</button>

관련 문제