开发者

toggle parent's element with parent

I have this structure

<p>Integer ac porta felis. <a href="#" class="despLeerMas">...read more</a></p>
<div class="none masInfodespLeerMas"> onsectetur adipiscing elit. Sed condimentum dictum vestibulum. Praesent odio dolor, dapibus et consectetur quis, pulvinar eu orci. Integer ac porta felis.<a href="#" class="ocultarLeerMas"> ...read less</a></div>

<p>Integer ac porta felis. <a href="#" class="despLeerMas">...leer más</a></p>
<div class="none masInfodespLeerMas"> onsectetur adipiscing elit. Sed condimentum dictum vestibulum. Praesent odio dolor, dapibus et consectetur 开发者_Go百科quis, pulvinar eu orci. Integer ac porta felis.<a href="#" class="ocultarLeerMas">..read less</a></div>

and i'm tring with this

$('.despLeerMas').click(function ()
    {
        $(this).parent().next('.masInfodespLeerMas').toggle();
        $(this).parent().next('.ocultarLeerMas').toggle();
        $(this).toggle();
        return false;
    });
    $('.ocultarLeerMas').click(function ()
    {
        $(this).parent().toggle();
         $(this).parent().parents('p').find('.despLeerMas').toggle();  ///cant' get it working
        $(this).toggle();
        return false;
    });

online here: http://jsfiddle.net/xwQGN/1/

The hidden is shown when clicking .despLeerMas (and .despLeerMas is hidden) when clicking .ocultarLeerMas the div is hidden again the problem is that .despLeerMas is not shown again :S (I can't get with the selection code, i guess)


Try:

$(this).parent().prev().find('.despLeerMas').toggle();

Your updated fiddle.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜