我的HTML代码是这样的:如何删除图像时显示加号按钮?
<input type='file' multiple style="display: none;" id="upload-file" />
<?php
for($i=0;$i<5; $i++) { ?>
<div class="img-container" id="box<?php echo $i ?>" data-status="0">
<button type="submit" class="btn btn-primary upload-add-product"<?php
if($i!=0) echo' style="display:none;"'; ?> >
<i class="glyphicon glyphicon-plus"></i>
</button>
<button style="display: none;" class="btn btn-danger show-button">
<i class="glyphicon glyphicon-trash"></i>
</button>
</div>
<?php } ?>
我的JavaScript代码是这样的:
...
$(document).on('click',".show-button",function(){
var imgTmpl = '<div class="img-container">'+
'<button style="display: none;" type="submit" class="btn btn-danger show-button">'+
'<i class="glyphicon glyphicon-trash"></i>'+
'</button></div>';
$(this).parent().remove();
$('body').append(imgTmpl);
});
演示和完整的代码是这样的:http://phpfiddle.org/main/code/9kb1-r47h
我的问题是:当我上传5张图片。然后我删除1张图片。 Plus图标不再出现。
我该如何解决这个问题?
您的追加错了按钮,你需要追加这个<键类型=“提交”类=“BTN BTN-初级上传-ADD -product “> \t \t \t \t – JYoThI
你应该追加满格与'plus'图标。 –
如果你用代码回答这个问题会更好。所以如果你的答案是正确的,我可以接受你的回答 –