지난 번에 2줄 이상일 경우 자세히보기 버튼이 추가되고... 닫기 버튼은 안 만들었는데 이번에 추가했습니다.
<style> .commentbox{overflow:hidden;} .commentbox .xe_content{margin-top:5px;} .commentbox .xe_content.hiddenComment p, .commentbox .xe_content.hiddenComment{ white-space:nowrap; word-wrap:normal; width:90%; overflow:hidden; text-overflow: ellipsis; float:left; } .commentbox .xe_content.hiddenComment p{width:100%;} .btn-moreComment{display:none;white-space:nowrap;float:right;padding-top:5px;} .btn-moreComment.hidden{display:none !important;} .btn-closeComment{ display:none; border: 0px solid #eee; padding: 0px 5px; vertical-align: middle; background: #fe989c; color: #fff; font-size: 12px; font-weight: 100; position: relative; margin-right: 5px; border-radius: 2px; height: 19px; float:right; cursor:pointer; margin-top:4px; } .btn-closeComment.active{ display:inline-block; } @media screen and (max-width: 533px){ .commentbox .xe_content.hiddenComment{ width:75%; } } </style> <div class="commentbox"> {$comment->getContent(false)} <div class="btn-moreComment"><자세히보기></div> <div class="btn-closeComment">[닫기]</div> </div> <script> jQuery(function ($) { var commentbox = $('.commentbox .xe_content'); commentbox.each( function() { $( this ).outerHeight(); if( $(this).outerHeight() > 21 ){ $(this).addClass('hiddenComment'); var btnMoreCmt = $(this).siblings('.btn-moreComment'); btnMoreCmt.show(); btnMoreCmt.on("click",function(){ $(this).siblings('.xe_content').removeClass('hiddenComment'); $(this).siblings(".btn-closeComment").addClass("active"); $(this).addClass("hidden"); }); //코멘트 닫기 var btnCloseCmt = $(this).siblings('.btn-closeComment'); btnCloseCmt.on("click",function(){ $(this).removeClass("active"); $(this).siblings('.xe_content').addClass('hiddenComment'); btnMoreCmt.removeClass("hidden"); }); } } ); }); </script> <!--@end-->