JSF中。当我单击第二个 img 然后单击下一步时,它不会更新。我想同时更新 next() 和 img 。这可能吗 ?
html:
<div class="myclass selected">
Content 1
</div>
<div class="myclass">
Content 2
</div>
<div class="myclass">
Content 3
</div>
<ul>
<li><img src="http://www.lillehammer.com/ImageVault/Images/id_2122/scope_66/ImageVaultHandler.aspx" /></li>
<li><img src="http://upload.wikimedia.org/wikipedia/commons/thumb/d/d7/Valued_image_seal.svg/40px-Valued_image_seal.svg.png" /></li>
<li><img src="http://www.iconico.com/i/icoImageFilterPro100.gif" /></li>
</ul>
<a class="next">next</a>
CSS:
.myclass {display:none;}
img {height: 20px; width: 20px; position: relative; display: block; margin: 20px; float: left;}
javascript:
$('img', 'ul').on('click', function() {
$(".myclass").eq($(this).parent('li').index()).show()
.siblings('div').hide();
});
$('.selected').show();
$(".next").click(function(){
var selected = $('.selected');
selected.removeClass('selected');
selected.hide();
var next = selected.next(".myclass");
if(next.length === 0) {
next = $(".myclass").first();
}
next.addClass('selected');
next.show();
});