Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <style>
- .small {height: 20px;}
- .big {height: auto;}
- </style>
- <div class="small">
- <p>Lorenter code hereem ipsum dolor sit amet, consectetur adipisicing elit, sed do
- eiusmod tempor incididunt ut labore et dolore magna aliqua.
- Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
- nisi ut aliquip ex ea commodo consequat. Lorem ipsum dolor sit amet,
- consectetur adipisicing elit, sed do eiusmod tempor incididunt
- ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis
- nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
- consequat.</p>
- <a href="#">Click to read more</a>
- </div>
- <script type='text/javascript'>
- $(window).load(function(){
- comment_reply = function (id){
- var e = $(id);
- e.toggle();
- }
- });
- </script>
- $('.wrapper').find('a[href="#"]').on('click', function (e) {
- e.preventDefault();
- $(this).closest('.wrapper').find('.small').toggleClass('small big');
- });
- $('.wrapper').find('a[href="#"]').on('click', function (e) {
- e.preventDefault();
- this.expand = !this.expand;
- $(this).text(this.expand?"Click to collapse":"Click to read more");
- $(this).closest('.wrapper').find('.small, .big').toggleClass('small big');
- });
- $(document).ready(function(){
- $(document).on('click', '.small a', function(){
- $('.small').addClass('big');
- $('.small').removeClass('small');
- });
- $(document).on('click', '.big a', function(){
- $('.big').addClass('small');
- $('.big').removeClass('big');
- });
- });
- .text.short {
- height: 50px;
- overflow: hidden;
- }
- .text.full {
- }
- .read-more {
- cursor: pointer;
- display: inline-block;
- font-weight: bold;
- padding: 3px;
- background-color: #06c;
- color: white;
- margin: 2px;
- }
- $(document).ready(function(){
- $(".read-more").click(function(){
- var $elem = $(this).parent().find(".text");
- if($elem.hasClass("short"))
- {
- $elem.removeClass("short").addClass("full");
- }
- else
- {
- $elem.removeClass("full").addClass("short");
- }
- });
- });
- [DEMO][2]
- $('.wrapper').find('a[href="#"]').on('click', function (e) {
- e.preventDefault();
- this.expand = !this.expand;
- $(this).text(this.expand?"Click to collapse":"Click to read more");
- $(this).closest('.wrapper').find('.small, .big').toggleClass('small big');
- });
- [2]: http://jsfiddle.net/mWcmg/1/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement