:file Selector - Javascript jQuery Selector

Javascript examples for jQuery Selector:file

Description

The :file selector selects input elements with type=file.

The following code shows how to select <input> elements with type="file":

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $(":file").css("background-color", "blue");
});//w ww .j  ava2s  .c om
</script>
</head>
<body>

<form action="">
  Name: <input type="text" name="user"><br>
  File: <input type="file" name="myfile">
</form>

<form action="">
  Name: <input type="text" name="user"><br>
  File: <input type="file" name="myfile">
</form>

</body>
</html>

Related Tutorials