我想删除以前的JQuery事件添加的类,但它不会玩球。请指导我!添加和删除类问题JQuery
这是应用类:
$('.project').click(function() {
var imageTotal = $(this).find('.gallery img').length;
if (imageTotal === 1) {
$('.next-image', this).hide();
$('.prev-image', this).hide();
} else {
$('.next-image', this).show();
$('.prev-image', this).show();
}
$('img.feature').hide();
$('.gallery img:nth-of-type(' + imageCounter + ')', this).addClass('current');
$(this).addClass('active');
});
而这正是我试图用其删除:
$('.back').click(function() {
$('.gallery').hide();
$('.back').hide();
$('img.feature').show();
$(this).parent('.project').find('div').removeClass('active');
$('.prev-page').show();
});
这是HTML结构:
<div class="project">
<img class="feature" src="content/dream1.jpg"/>
<div class="description">
<h3>Exhibition Roadshow</h3>
<h4>The Royal Borough of Kensington and Chelsea 2012</h4>
</div>
<div class="gallery">
<img src="content/dream2.jpg"/>
<img src="content/dream3.jpg"/>
<img src="content/dream4.jpg"/>
<img src="content/dream5.jpg"/>
<div class="next-image">→</div>
<div class="prev-image">←</div>
</div>
<div class="back">S</div>
</div>
你可以看到活的例子here,如果有帮助...
哪里是'imageCounter'界定? – hexblot
@hexblot - 请看看实时链接。通过复制和粘贴来解释比我更容易。谢谢。 – JohnRobertPett