html 5 怎么使其他元素有file功能

html 5 怎么使其他元素有file功能,第1张

html 5 怎么使其他元素有file功能,我的做法是用js控制触发。

做法:

<div style="position: absoluteleft: 0top: 0right: 0bottom: 0width: 100%height: 100%">

    <p>

<button id="btn1" type="button">请选择文件1</button>

<input type="file" name="file1" id="file1" style="display: none"/>

    </p>

    <p>

<span id="btn2" style="cursor: pointer">请选择文件2</span>

<input type="file" name="file2" id="file2" style="display: none"/>

    </p>

</div>

<script type="text/javascript">

    $('#btn1').on("click",function(){

$("#file1").click()

    })

    $('#btn2').on("click",function(){

        $("#file2").click()

    })

</script>

要在哪里添加

假如:

<div

id="mydiv">

在此添加inputinput

type=file </div>

$('#mydiv').appendChild("<input

type=‘file’/>")

为在 id="mydiv"的元素的最后一个子元素后面添加


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/bake/11424884.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-16
下一篇 2023-05-16

发表评论

登录后才能评论

评论列表(0条)

保存