Home >>jQuery Tutorial >jQuery file Selector

jQuery file Selector

jQuery file Selector

jQuery file selector in jQuery is used to selects input elements with type=file.

Syntax:
$(":file")
Here is an Example of jQuery :file Selector

<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$(":file").css("background-color", "#c0ed1f");
});
</script>
</head>
<body>
<form action="">
Name: <input type="text" name="user"><br><br>
File: <input type="file" name="myfile">
</form>
</body>
</html>

Output:
Name:

File: