Search code examples
jqueryselectonclicktextareaonfocus

No text area should be selected in jQuery


I have a form, and I want that the first text area would not be selected. No textarea should be selected first. I want the user to click on the textarea on their own in jQuery.


Solution

  • You can execute something like this:

    jQuery("textarea").blur();
    

    It makes all textareas on your page lose focus.

    UPDATE:

    You're using text inputs too, so add:

    jQuery("input[type=text]").blur();
    

    So add this to a script file/script tag in the head of your page:

    jQuery(document).ready(function(){
        jQuery("textarea").blur();
        jQuery("input[type=text]").blur();
    });