Skip to content
Advertisement

Select all contents of textbox when it receives focus (Vanilla JS or jQuery)

What is a Vanilla JS or jQuery solution that will select all of the contents of a textbox when the textbox receives focus?

Advertisement

Answer

$(document).ready(function() {
    $("input:text").focus(function() { $(this).select(); } );
});
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement