English 中文(简体)
如何从使用j Query的档案材料中获取档案名称?
原标题:How to capture the filename from a file input using jQuery?

我的表格有文件输入控制:

<input type="file" onclick="this.blur()" name="descFile" />

因此,当用户选择文件时,在案文输入箱中显示的道路(浏览器的行为)时,BUT希望我用黑体字发出以下信息:他们选择文件上载,prior to postback

Is there a way using Javascript to somehow capture the "select" event from file input and display in bold letters below the file input?

最佳回答
$( input[name="descFile"] ).change(function(){
   var filename = $(this).val();
   $( <label>Filename selected:  + filename + </label> ).insertAfter($(this));
});

2. 注意将其放在或类似于:

$(function(){ });
问题回答

这样做就象这样。

$( input[type=file] ).val()

无论如何,我建议使用名称或ID属性来选择你们的意见。 顺便说一句:

$( input[type=file] ).change(function(e){
  $in=$(this);
  $in.next().html($in.val());
});

如果我理解你的问题,它就把你的意见打上“。

$( #file_attach ).change(function(){

        path=$(this).attr( value );
        start = path.lastIndexOf(".");
        alert("extention: "+start);
});




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签