2013-09-29 4 views
0

여기에 주요 내용을 표시/숨기고 기본 WordPress 페이지에서 발췌문을 표시하여 내 문제를 부분적으로 해결 한 코드가 있습니다. 추가 버튼을 클릭하면 발췌가 갑자기 사라지고 주 콘텐츠가 표시되지 않습니다.WordPress jQuery를 사용하여 발췌 내용과 토글 전환

JQuery는 가장 중요한 부분이 아니므로 도움을 주시면 대단히 감사하겠습니다.

$(function() { 
$('.mainContent').hide(); 
$('a.read').click(function() { 
    $(this).parent('.excerpt').hide(); 
    $(this).closest('.tenant').find('.mainContent').slideDown('fast'); 
    return false; 
}); 
$('a.read-less').click(function() { 
    $(this).parent('.mainContent').slideUp('fast'); 
    $(this).closest('.tenant').find('.excerpt').show(); 
    return false; 
}); 
}); 


<div class="excerpt"><?php the_excerpt(); ?><a href="" class="read">Read More</a> </div> 
<div class="mainContent"><?php the_content(); ?><a href="" class="read-less">Read Less</a></div> 

답변

0

이 시도 :

$(function() { 
    $('.mainContent').hide(); 
    $('a.read').click(function() { 
     $(this).parent('.excerpt').slideUp('fast'); 
     $(this).closest('.tenant').find('.mainContent').slideDown('fast'); 
    //  $('.mainContent').show(); 
     return false; 
    }); 
    $('a.read-less').click(function() { 
     $(this).parent('.mainContent').slideUp('fast'); 
     $(this).closest('.tenant').find('.excerpt').slideDown('fast'); 
     return false; 
    }); 
}); 

데모 here

+0

를 TRY 여전히 그 코드에 똑같은 문제가있어서 링크를 클릭하여 작동하게했을 때 기본 .show. hide 코드를 썼습니다. 어쨌든 도움을 주셔서 감사합니다! – user2480082

+0

@ user2480082, 데모를 보았습니까? 너는 어떤 영향을 미쳤습니까? – Sergio

+0

데모가 왜 내 테스트 사이트에서 작동하지 않는지 알지 못했습니다. 나는 정말로 트릭을했을 온라인에 걸쳐 온 몇 가지 코드였던 어떤 효과를 찾지 못했습니다. 그래서 제가 제거한 부분은 정말로 필요하지 않았습니다. – user2480082

-1

을 당신은 .tenant

누락 된 본

<article class="tenant"> 
<div class="excerpt"><?php the_excerpt(); ?><a href="" class="read">Read More</a> </div> 
<div class="mainContent"><?php the_content(); ?><a href="" class="read-less">Read Less</a> </div> 
</article>