0

我的 HTML 看起来像

<h3><a href="#" title="story title">Story Title</a>
    <img class="expandstory" src="/images/plus.png" /></h3>
<div class="description">Short description about the story</div>

我需要 jquery,当用户单击 expandstory 图像时,它将扩展描述。

我用了`

$(".expandstory").click(function()  {
     $(".description").slideUp(500);
     $(this).nextAll('.description:first').slideToggle(500);
}`

但没有用。请给我一个解决方案。提前致谢。

4

2 回答 2

3

尝试这个:

$(".expandstory").click(function()  {
     $(".divisionWrap div ul").slideUp(500);
     $(this).parent().nextAll('.description:first').slideToggle(500);
});

此外,作为建议,您不需要使用 nextAll() 查看逻辑。

你可以这样做:

$(this).parent().next('.description').slideToggle(500);
于 2013-04-30T10:12:29.883 回答
1

尝试

$(".expandstory").click(function()  {
     var el = $(this).closest('h3').next('.description');
     $(".description").not(el).slideUp(500);
     el.slideToggle(500);
}
于 2013-04-30T10:13:47.947 回答