无法在关闭时从jQuery库中删除子项 [英] can't remove child from jQuery gallery on close
问题描述
Noob就此。上周开始使用jQuery,在阅读本网站大约10个小时之后,api不得不问这个并希望有方向。
Noob at this. Started using jQuery last week and after about 10 hours of reading this site and the api have to ask this and hope for a direction.
试图删除最后一个点击的图片一个图库,所以单击下一个图库将加载第一个图像而不是最后一个图像。 (www.cooloradan.com)。
Trying to remove the last image clicked from a gallery, so next gallery clicked will load first image instead of last image. (www.cooloradan.com).
我的janky代码(主要来自其他人):
My janky code (taken mostly from someone else):
function loadPhoto($url, $caption) {/*Image pre-loader*/
showPreloader();
var img = new Image();
$(img).load( function() {
$(img).hide();
hidePreloader();
}).attr({ "src": $url });
$('#largephotoc1').css('background-image','url("' + $url + '")');
$('#largephotoc1').data('caption', $caption);
$('#largephotoc2').css('background-image','url("' + $url + '")');
$('#largephotoc2').data('caption', $caption);
$('#largephotoc3').css('background-image','url("' + $url + '")');
$('#largephotoc3').data('caption', $caption);
$('#largephotoc4').css('background-image','url("' + $url + '")');
$('#largephotoc4').data('caption', $caption);
$('#largephoto3d1').css('background-image','url("' + $url + '")');
$('#largephoto3d1').data('caption', $caption);
}
/* When a thumbnail is clicked*/
$('.thumb_container').click(function() {
var handler = $(this).find('.large_image');
var newsrc = handler.attr('src');
var newcaption = handler.attr('rel');
loadPhoto(newsrc, newcaption);
});
$('.close-reveal-modal').click(function() {
$('.thumb_container').find('.large_image').remove();
});
html:
<div id="myModalc3" class="reveal-modal">
<div class="mainframe">
<div id="largephotoc3">
</div>
</div>
<div class="thumbnailimage">
<div class="thumb_container">
<div class="large_thumb">
<img src="images/album/modalthumbs/3d1.6.jpg" class="large_thumb_image" alt="thumb" />
<img alt="" src="images/album/modallarge/3d1.6.jpg" class="large_image" />
</div>
</div>
</div>
<a class="close-reveal-modal"><img src="images/icons/close.png" /></a>
</div>
</div>
我不知道我到底要问的是什么,但我会继续寻找我整晚都在尝试不同的事情。我很确定。
I don't know exactly what I'm trying to ask, but I'll keep looking and trying different things all night I'm sure though.
推荐答案
对你的部分问题有点困惑,但我想你是什么想要改变这个......
A little confused about parts of your question, but I think what you want is to change this...
$('.close-reveal-modal').click(function() {
$('.thumb_container').find('.large_image').remove();
});
到此......
$('.close-reveal-modal').click(function() {
$(this).prev().find('.large_image').remove();
});
这篇关于无法在关闭时从jQuery库中删除子项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!