开发者

Jquery slidetoggle was working now not

开发者 https://www.devze.com 2023-01-27 15:10 出处:网络
I have the following structure: <div class=\"news\"> <p> summary here<a href=\"#\">more</a>

I have the following structure:

    <div class="news">

 <p>   
  summary here<a href="#">more</a>
 </p>
<div class="more">
 <p>
  More News
 </p>
</div>

with the following jQuery

    $('.news a').click(function(event){
 //alert('.news');
 $(this).nextAll(开发者_高级运维'.more').slideToggle();
 event.preventDefault();
});

For some reason it has stopped working, any ideas


.nextAll() finds siblings only, but you're inside a <p> now...so you need to go up one level:

$('.news a').click(function(event){
  $(this).parent().nextAll('.more').slideToggle();
  event.preventDefault();
});
0

精彩评论

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