You could maybe try this(你也许可以试试这个)
$('.box').click(function() {
if ($(this).html() === 'click to add photo') {
var src = prompt('what is the image address of what you wish to see')
if(src!==null){
$(this).html("<img src='" + src + "'/>")
}else{
$(this).html('click to add photo');
}
} else {
var src = prompt('what is the image address of what you wish to see')
$(this).append("<img src='" + src + "'/>")
}
})
<div class="box">click to add photo</div>
<div class="box">click to add photo</div>
<div class="box">click to add photo</div>
<div class="box">click to add photo</div>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…