Search code examples
javascriptjqueryhtmlprototypejsequivalent

What is the jQuery equivalent of the Prototype function .activate()


Prototype's activate function

Gives focus to a form control and selects its contents if it is a text input

according to the Prototype website. i.e.

$('my_element_id').activate();

What is the equivalent function in jQuery?


Solution

  • $('#my_element_id').focus();
    

    which is a shortcut for

    $('#my_element_id').trigger('focus');
    

    http://api.jquery.com/focus/