开发者

How to get all input controls which are of type file in jquery

I want to get all the file upload controls on my page, Im adding multiple file upload control so i dont have any idea how many they can be but i have to get 开发者_如何学Goall of them in jquery. Im using asp.net mvc and jquery


Use:

$(':file').each(function(){
  // your code to handle input type files.
});

Or:

$('input[type="file"]').each(function(){
  // your code to handle input type files.
});

More Info:

http://api.jquery.com/file-selector/


When do you want to get the input field? after clicking a button? or changing the input field? if you add dynamic the input field than you can maybe better use the live option.

$('input[type="file"]').live("blur",function(){
        $('input[type="file"]').each(function(){
              // you can put your code here
            });
    });

see: http://api.jquery.com/live/

above code is from jQuery 1.4

Better give more information next time

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜