Jquery - Start a function after open button (from input="file") is pressed
how can I start a function after the open* button is pressed?
html
<form id=开发者_开发百科"xxx">
<input id="yyy" type="file" />
</form>
js
$(function(){
$('body').append('jq works <br />');
$("#xxx").submit(function ()
{
$('body').append('start function<br />');
});
});
jsfiddle http://jsfiddle.net/vGBaK/
edit:
I mean this button ->You can use the change event, it wont fire if the same file is selected but if you also clear on the click event it should work.
see this JSFiddle
$(function(){
$('body').append('jq works <br />');
$("#xxx").submit(function ()
{
$('body').append('go >> <br />');
});
$("#yyy").change(function(){
alert("changed");
}).click(function(){
$(this).val("")
});
});
Here I assume open* button means browse button of your file input box,
$("#yyy").click(function(){
//alert("button clicked")
// write your code
})
精彩评论