我正在开发一个应用程序,有人可以选择多个图片从一个画廊。我附加了一个按钮,每一个图片,调用函数的点击。如何删除附在按钮上的图像?
<div id="images">
<img src="www.xyz.com/qwert.jpg" class="hi">
<input type="button" class="multiple">
<img src="www.xyz.com/qwerty.jpg" class="hi">
<input type="button" class="multiple">
<img src="www.xyz.com/qwertww.jpg" class="hi">
<input type="button" class="multiple">
</div>发布于 2015-07-06 08:22:53
您可以使用以下代码:
$(".multiple").click(function () {
$(this).prev("img").remove();
});片段
$(function () {
$(".multiple").click(function () {
$(this).prev("img").remove();
});
})<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<div id="images">
<img src="www.xyz.com/qwert.jpg" class="hi">
<input type="button" class="multiple">
<img src="www.xyz.com/qwerty.jpg" class="hi">
<input type="button" class="multiple">
<img src="www.xyz.com/qwertww.jpg" class="hi">
<input type="button" class="multiple">
</div>
https://stackoverflow.com/questions/31240906
复制相似问题