开发者

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();
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜