0

jQueryでのトラバースに問題があります..うまくいけば簡単なものです..しかし、私は頭をぶつけています。私は試しました.closest()、、.next()...find()そしてnada

HTML:

<div class='news_box'>
    <img src='".NEWS.$n[image]."' alt='$n[title] Image' class='news_img' />
    <div class='news_text'>
        <h3>$n[title] // ".date("d.m.Y", strtotime($n[created_on]))." // ".date("H.i", strtotime($n[created_on]))."</h3>
        <p>".substr(strip_tags($n[description]), 0, 90)."... <span title='Read More On $n[title]' class='more'>Read More</span></p>
    </div>
    <p class='clear'></p>
    <div class='full_item'>
        $n[description]
    </div>
</div><!--close news_box-->

Jクエリ:

$(".news_box span.more").click(function(){
    $(this).next(".full_item").show();
});

CSS.full_itemはに設定されていdisplay:none ます目的は、スパンのクリック時に div: full_item を表示することです.more

前もって感謝します!

4

5 に答える 5

2

.moreは の中にありp、 は の中.news_textにあり、.full_itemその兄弟です。したがって、次のようにする必要があります。

$(this).closest('.news_text').siblings('.full_item').show();

。兄弟()

于 2012-04-04T14:15:06.640 に答える
0

spanは.full_itemの兄弟ではありません。試す

$(this).parent().nextAll(".full_item").show();

また、.full_itemがpの親の直後にないため、関数は機能しnext ません。nextAll代わりに使用してください。

于 2012-04-04T14:15:16.153 に答える
0

私はソリューションをjsfiddleに入れました:

http://jsfiddle.net/55mUj/

$(".news_box span.more").click(function(){
    $(this).closest('.news_text').siblings('.full_item').show();
});​
于 2012-04-04T14:28:29.863 に答える
-1
$(this).parent().next(".full_item").show();
于 2012-04-04T14:15:07.530 に答える
-1
$(".news_box span.more").click(function(){
   $(this).closest(".news_box").next(".full_item").show();
});

動作するはずです。

于 2012-04-04T14:16:26.240 に答える