這是我的代碼:跨瀏覽器的造型 「選擇文件」 按鈕
HTML:
<form>
<input id = "file" type="file" />
<div id="custom_button">custom button</div>
</form>
的Jquery:
$("#custom_button").on("click", function() {
$("#file").click();
});
CSS:
#file {
display: none;
}
但這個作品只有在Firefox和鉻,在safari和歌劇,在clic鉀對custom button
,窗口文件選擇並沒有叫
DEMO:http://jsfiddle.net/J4GdN/
Qusetion:爲什麼這不是在Safari和Opera的作品?什麼是替代方案,在這些瀏覽器中做到這一點?
它適用於我在Safari上。 – undefined 2013-05-01 11:39:46
http://stackoverflow.com/questions/210643/in-javascript-can-i-make-a-click-event-fire-programmatically-for-a-file-input – dt192 2013-05-01 11:44:41
http://stackoverflow.com/questions/12035400/how-can-i-remove-the-no-file-chosen-tooltip-from-a-file-input-in-chrome – undefined 2013-05-01 11:45:33