jQuery Selector :file

Introduction

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

Syntax

$(":file")

Select <input> elements with type="file":

$(":file")

View in separate window

<!DOCTYPE html>
<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", "red");
});//w  w w. j a  va 2  s .c  om
</script>
</head>
<body>

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

</body>
</html>



PreviousNext

Related