Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 671
Mike Webb Avatar asked Aug 24 '10 18:08

Mike Webb


People also ask

What is jQuery prototype?

All objects have a prototype property. It is simply an object from which other objects can inherit properties. The snippet you have posted simply assigns an object with some properties (such as init ) to the prototype of jQuery , and aliases jQuery.prototype to jQuery.fn because fn is shorter and quicker to type.

What is fn in jQuery?

fn is an alias for jQuery. prototype which allows you to extend jQuery with your own functions. For Example: $.fn.

What is $() in Javascript?

The $() function The dollar function, $(), can be used as shorthand for the getElementById function. To refer to an element in the Document Object Model (DOM) of an HTML page, the usual function identifying an element is: document.


1 Answers

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

which is a shortcut for

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

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

like image 175
jAndy Avatar answered Sep 22 '22 05:09

jAndy