how to do only this div
<div id="container">
<div class="slides">
<div class="slides_container">
<p>1</p>
<p>2</p>
<p>3</p>
</div>
<a href="#" cla开发者_运维问答ss="prev">Prev</a>
<a href="#" class="next">Next</a>
</div>
</div>
<div id="container">
<div class="slides">
<div class="slides_container">
<p>1</p>
</div>
<a href="#" class="prev">Prev</a>
<a href="#" class="next">Next</a>
</div>
</div>
var n = $(".slides_container > p").length;
if (n == 1) {
$(".prev", ".next").hide();
} else {
$(".prev", ".next").show();
}
If "P" = 1 , i will hide .prev & .next (ONLY THIS DIV)
HOW TO ? THANKS :D
This will iterate over each group of slides, and toggle the visibility of the prev and next links depending on how many p elements are present.
$('div.slides').each(function() {
$('.prev,.next', this).toggle(
$('.slides_container > p', this).size() > 1
);
});
Use the comma to specify multiple selectors and wrap them all in single/double quotes together:
if (n > 0) {
$(".prev, .next", $('#container ')).hide();
}
else {
$(".prev, .next", $('#container ')).show();
}
精彩评论