jQuery :file Selector

jQueryWeb DevelopmentFront End Technology

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

Syntax

The syntax is as follows −

$(":file")

Example

Let us now see an example to implement the :file() selector −

<!DOCTYPE html>
<html>
<head>
<style>
   .demo {
      background-color: blue;
      color: white;
      font-size: 16px;
      border: 2px blue dashed;
   }
</style>
<script src="https://code.jquery.com/jquery-3.4.1.js"></script>
<script>
   $(document).ready(function(){
      $(":file").addClass("demo");
   });
</script>
</head>
<body>
<h2>Job Application</h2>
<form action="">
Applicant Name: <input type="text" name="cname"><br>
Rank: <input type="number" name="rank"><br><br>
Resume: <input type="file" name="myfile">
</form>
</body>
</html>

Output

This will produce the following output −

raja
Published on 05-Nov-2019 07:23:07
Advertisements