How to use jQuery to get the current value of a fi

2020-08-09 06:20发布

From what I've ready you should be able to use the 'value' property of a file input field to get the currently set path of that field. But when I do this:

 $('#fileinput').value()

I get 'undefined'. The ID of the field is set to "fileinput" I'm sure. Does anyone have any thoughts on why this might not be working for me?

And by the way, this works:

var d = document.getElementById('AttachmentFile');
alert(d.value);

So I guess this has something to do with the way jQuery works that I don't fully understand.

Thanks!

8条回答
成全新的幸福
2楼-- · 2020-08-09 06:55

I think it should be

 $('#fileinput').val();
查看更多
女痞
3楼-- · 2020-08-09 06:56

You need to use val rather than value.

$("#fileinput").val();
查看更多
登录 后发表回答