--- 更新的问题 ---
感谢所有的答案。我在我的JS 实践中编写了 JS 代码,用于在单击相应按钮时删除父 div !
然而,相同的 JS 代码在我的真实 JS 项目中不起作用,其中所有父 div 都是动态创建的。完整的代码可以在下面找到。
没有错误,但是 JS 代码不起作用。有任何想法吗?
下面是简化的 **真正的 JS 项目 ** 完整代码
<html>
<head>
<meta charset="UTF-8">
<title>Upload Imgs</title>
<style type="text/css">
.container {
width: 100%;
}
.display-area {
width: 100%;
height: auto;
display: flex;
justify-content: flex-start;
flex-wrap: wrap;
}
img {
max-width: 100%;
}
.image-preview {
width: 80%;
min-height: 300px;
border: 2px dashed #dddddd;
display: block;
/*default text*/
display: flex;
align-items: center;
justify-content: center;
font-weight: bold;
color: #cccccc;
}
.newbtns {
border: 0;
background: lightgrey;
text-shadow: 1px 1px 1px white;
border: 1px solid #999;
position: absolute;
display: block;
}
</style>
</head>
<body>
<div class="container">
<div id='inputFiles'><input type="file" class="file" name="image_uploads" accept="image/png, image/jpeg, image/jpg"
multiple></div>
<div class="display-area" id='imgDisplay'>
</div>
<div id="defaultContent">
<p>No images</p>
</div>
<button type="button" value="Reload page" onclick="window.location.reload()">Reload Page</button>
</div>
</div>
</body>
慕尼黑8549860
PIPIONE
FFIVE
ABOUTYOU
相关分类