Select Form File upload $(":file") in jQuery
Description
The following code shows how to select Form File upload $(":file").
Example
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){<!--from ww w . j a v a2 s . c o m-->
alert($(":file").length);
});
</script>
</head>
<body>
<input type="button" value="Input Button"/>
<input type="checkbox">java2s.com</input>
<input type="checkbox" />
<input type="checkbox" />
<input type="file" />
<input type="hidden" />
<input type="image" />
<input type="password" />
<input type="radio" />
<input type="reset" />
<input type="submit" />
<input type="text" />
<select><option>Option<option/></select>
<textarea></textarea>
<button>Button</button>
</body>
</html>
The code above generates the following result.
...
Get all form elements in different ways in ...
Get first element in query set in jQuery
Get list item index in jQuery
Get parent for a form input element in jQue...
Get the count of input elements in jQuery
Get the last span just added to a paragraph...
Get the length for matched element list in ...
Get the tag name of the element clicked on ...
Map parent elements to get all their names ...
Mark under line by content $("div:contains(...
Match all elements including head, body, et...
Match input element with attribute-begin-wi...
Reference current element its event handler...
Remove an element by its contents $("p") in...
Select Form Checkbox with Form Checkbox sel...
Select Form Checked box $("input:checked") ...
Select Form Disabled form element $("input:...
Select Form Enabled form element $("input:e...
Select Form Password field with Form Passwo...
Select Form Radio button with Form Radio bu...
Select Form Reset button $(":reset") in jQu...
Select Form Selected option element $("sele...
Select Form Submit button with Form Submit ...
Select Form button $(":button") in jQuery
Select Form text fields with form text fiel...
Select Header element with header element s...
Select LI list element by index in jQuery
Select all LI elements for a UL element and...
Select all div tags $("div") in jQuery
Select all elements that are the first chil...
Select all elements that are the last child...
Select all elements that are the nth-child ...
Select all elements that are the only child...
Select all elements under a certain element...
Select all p elements inside a div in jQuer...
Select all previous tags and set styles in ...
...
Get all form elements in different ways in ...
Get first element in query set in jQuery
Get list item index in jQuery
Get parent for a form input element in jQue...
Get the count of input elements in jQuery
Get the last span just added to a paragraph...
Get the length for matched element list in ...
Get the tag name of the element clicked on ...
Map parent elements to get all their names ...
Mark under line by content $("div:contains(...
Match all elements including head, body, et...
Match input element with attribute-begin-wi...
Reference current element its event handler...
Remove an element by its contents $("p") in...
Select Form Checkbox with Form Checkbox sel...
Select Form Checked box $("input:checked") ...
Select Form Disabled form element $("input:...
Select Form Enabled form element $("input:e...
Select Form File upload $(":file") in jQuer...
Select Form Image button with Form Image bu...Select Form Password field with Form Passwo...
Select Form Radio button with Form Radio bu...
Select Form Reset button $(":reset") in jQu...
Select Form Selected option element $("sele...
Select Form Submit button with Form Submit ...
Select Form button $(":button") in jQuery
Select Form text fields with form text fiel...
Select Header element with header element s...
Select LI list element by index in jQuery
Select all LI elements for a UL element and...
Select all div tags $("div") in jQuery
Select all elements that are the first chil...
Select all elements that are the last child...
Select all elements that are the nth-child ...
Select all elements that are the only child...
Select all elements under a certain element...
Select all p elements inside a div in jQuer...
Select all previous tags and set styles in ...
...