Again wp loop ...

There is a code

<?php /*Start the loop*/ ?> <?php $specialistquery = new WP_Query('category_name=our-specialists'); ?> <?php while ( $specialistquery->have_posts()) : $specialistquery->the_post()?> <div class="full clear"> <img class="close-full" src="" alt="Закрыть"> <div class="full-info clear"> <?php the_post_thumbnail(); ?> <p class="name visible"><?php the_title() ?></p> <div class="post-content"> <?php get_template_part( 'template-parts/content' ); ?> </div> <p class="specialization visible"></p> <p class="education visible"></p> <p class="experience visible">Стаж более лет</p> </div> </div> <?php endwhile; ?> <script type="text/javascript"> $('.close-full').click(function(){ $(this).find('.post-content').css({'display':'none'}); }); $('.full').click(function(){ $(this).find('.post-content').css({'display':'inline'}); }); </script> 

The bottom line is that when you click on the div it opens and a full info appears with the close button. When you click close, the div should collapse to its original state.

div appears but close-full does not work. Nothing happens at all.

I suspect that it's all about parents, etc. Only I can not understand what to become attached to.

    1 answer 1

     $('.close-full').click(function(){ $(this).next('div').find('.post-content').css({'display':'none'}); }); $('.full').click(function(){ $(this).find('.post-content').css({'display':'inline'}); $(this).find('.specialization').css({'display':'none'}); $(this).find('.education').css({'display':'none'}); $(this).find('.experience').css({'display':'none'}); $(this).find('.full-info').css({'cursor':'auto','background-color':'#f1f5f5','box-shadow':'7px 5px 0 rgba(228,231,231,1)'}); $(this).find('.close-full').css({'display':'block'}); $(this).find('.attachment-post-thumbnail').css({'margin':'0 30px 25px 0','width':'300px','height':'300px'}); }); 
     <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <div class="specialist-content"> <img class="close-full" src="" alt="Закрыть"> <div class="full clear"> <div class="full-info clear"> the_post_thumbnail() <p class="name visible">php the_title()</p> <div class="post-content"> get_template_part( 'template-parts/content' ) </div> <p class="specialization visible"></p> <p class="education visible"></p> <p class="experience visible">Стаж более лет</p> </div> </div></div> 

    • I made a little mistake by asking my question. .close-full is inside .full. As I understand it, I need to get to the .full using the selector. But nothing works. The idea is to approach prev () but no - Spiridon Robakidze
    • if I understand you correctly, then you want so jsfiddle.net/2f89fya7 ? - vital mar