rakeshr

jquery select parent and then childrens

Sep 13th, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 0.98 KB | None | 0 0
  1. <script>
  2. jQuery( document ).ready(function() {
  3.     jQuery('.more, .lessbutton').hide();
  4.     jQuery('.postbox').on('click', '.morebutton', function(){
  5.          jQuery(this).closest('.postbox').children('.postcontent').children('.less').hide();
  6.          jQuery(this).closest('.postbox').children('.buttons').children('.morebutton').hide();
  7.          jQuery(this).closest('.postbox').children('.postcontent').children('.more').show();
  8.          jQuery(this).closest('.postbox').children('.buttons').children('.lessbutton').show();
  9.     });
  10.     jQuery('.postbox').on('click', '.lessbutton', function(){
  11.          jQuery(this).closest('.postbox').children('.postcontent').children('.less').show();
  12.          jQuery(this).closest('.postbox').children('.buttons').children('.morebutton').show();
  13.          jQuery(this).closest('.postbox').children('.postcontent').children('.more').hide();
  14.          jQuery(this).closest('.postbox').children('.buttons').children('.lessbutton').hide();
  15.     });
  16. });
  17. </script>
Add Comment
Please, Sign In to add comment