In short and simple: because :select does not exist.
$('select') will work , but only if there is a <select> element in your code. You did not specify above in your code.
See the list of selectors .
:input exists instead :
Selects all input elements, textarea, select, and button.
In general: Selectors starting with a colon : are pseudo-selectors. They are defined by jQuery (they are not valid CSS selectors) and select elements with a specific state or property).
You have already encountered :input . He selects all form controls. Another is, for example : visible , which selects all displayed (visible) elements.
Update:
<select> elements must exist when $('select').focus(... is executed. I donβt know what software you use, but if they load elements, for example through Ajax, then most likely they still do not exist when your code is executed.
source share