There is a file input, it is necessary that when you click for example, the <a>Выбрать файл</a>
link clicks on input and selects a file. click () does not work in all browsers, but focuc () does not work at all, how will it get out?
|
4 answers
It is possible to implement this using a trigger. See example
- libraries said not to use) - ashorva
- >>. click () does not work in all browsers, but focuc () does not work at all - ashorva
- @ashorva, probably ... I did not check it in IE5.5, but it is possible that it will not work in it. Oh, byad ... Besides, I checked it in the version 7+, FF, Opera, Safari. Here, oddly enough, it works. - Deonis
|
And it is very good that does not work ...
The principle is this: put a transparent input type = file on top of the link, so that its coordinates coincide with the border of the link. It turns out that the click "as if by reference" will actually occur on the input path.
- what is good?) - ashorva
- 3The fact that the ability to automatically submit a form is standard and always is. Explain how it can be dangerous if the input file will support ALL events? - user6550
- Understood ) By the way, the fox supports click () - ashorva
- Yes, explain. Because to put the file in this input without user intervention still does not work. - Qwertiy ♦
|
so that when you click, for example, the link
<a>Выбрать файл</a>
click on input and select the file
Well, then replace the link to the label Why wonder?
|
label for=id
not suitable? Try inputEl.trigger("click")
.
|