In jQuery, what is basic difference between .select()
& focus()
and what are their appropriate using places?
They have their differences:
.select()
: will fire when TEXT is selected.
<input>
and <textarea>
elements..focus()
: will fire when an element receives focus i.e. an input box is clicked on, tabbed into, etc.
<input>
, <select>
, <a>
From the jQuery documentation:
select
The select event is sent to an element when the user makes a text selection inside it. This event is limited to
<input type="text">
fields and<textarea>
boxes.
focus
The focus event is sent to an element when it gains focus. This event is implicitly applicable to a limited set of elements, such as form elements (
<input>
,<select>
, etc.) and links (<a href>
). In recent browser versions, the event can be extended to include all element types by explicitly setting the element's tabindex property.