Home » jQuery :file selector

jQuery :file selector

by Online Tutorials Library

jQuery :file selector

The :file selector in jQuery is used to select the elements with the type = “file”.


The commonly used syntax of using the :file selector is given as follows –

The selector is used without any argument. A form can contain more than one file element. We can select any specific input element with type = “file” using the class or id of an element.

Let’s see an illustration to understand the working of the :file selector.


It is a simple example of using the :file selector. In this example, there are three input fields one is of type = “text”, the other one is of type = “password”, and the last one is of type = “file”. On clicking the given button, the :file selector will select the input field with the type = “file”.

Test it Now


After the execution of the above code, the output will be –

jQuery :file selector

On clicking the given button, the background-color of the input field with type = “file” will be changed, as shown in the below screenshot –

jQuery :file selector

You may also like