<input type="file" name="" id="fileIds1" multiple /> <div id="fangInput"></div>
<script type="text/javascript"> $("#fileIds1").change(function(){ console.log(1); var fileObj1 = document.getElementById("fileIds1").files; // js 获取文件对象 for(var i = 0; i < fileObj1.length; i++) { var btnC = 'del-btn' $("#fangInput").append('<p for="message-text" class="control-label" style="width: 100%;height: auto;word-wrap:break-word;word-break:break-all;overflow: hidden">文件名:' + fileObj1[i].name + ' <button type="button" onclick="fangDelete()" class= btnC style="background-color:#dc4739;color:#fff;margin-top:3px">删除文件</button>'); } console.log(fileObj1); }) function fangDelete(){ console.log(event); var fangInput=document.getElementById("fangInput"); console.log(fangInput); var lis=fangInput.getElementsByTagName("button"); console.log(lis); } </script>
慕斯709654
慕妹3146593
相关分类