jquery Text Folding

Source: Internet
Author: User

/** * Created by Dongdong on 2015/4/28.*/(function($){    varDefaults ={height:40,//height after text is closedSpeed: ' Normal ',//speed of text unwinding and unwindingdown:{"class": "Fold-down", "Text": "Expand"},//Expanded Stylesup:{"class": "Fold-up", "text": "Close"}//style of the collection    }; $.fn.accordiontext=function(options) {Options=$.extend (defaults,options); return  This. each (function(){            varc = $ ( This), H=c.height (), Ph= parseint (C.css ("Padding-top"). Replace ("px", "")) +parseint (C.css ("Padding-bottom"). Replace ("px", "" ")), T= $("#"+$( This). Data (' Switch ')); C.css ({overflow:"Hidden", height:options.height + ph + "px"}); T.toggle (function(){                    $( This). Text (Options.up.text). Removeclass (Options.down.class). addclass                    (Options.up.class); C.animate ({height:h+ph + "px"},options.speed); },                function(){                    $( This). Text (Options.down.text). Removeclass (Options.up.class). addclass                    (Options.down.class); C.animate ({height:options.height+ph + "px"},options.speed);        }). Text (Options.down.text). addclass (Options.down.class);    }); }}) (JQuery);

Call (the bootstrap icon style is used here):

        $ (function() {            $ (". Text"). Accordiontext ({                down:{"class": "Glyphicon Glyphicon-chevron-down "," Text ":" "},                up:{" class ":" Glyphicon glyphicon-chevron-up "," Text ":" "}            }) ;        });

Html:

<styletype= "Text/css">. Switch{text-align:Center;cursor:Pointer;Height:20px;Line-height:20px;}. Text{padding:3px;}    </style><Div>    <Divclass= "Text bg-success"Data-switch= "BTN2">Soda Green on the plane to see the place is the leader saw Phillips weight loss intersection to pay the electricity and power junction is junction with Soda Green on the plane to see the place is the leader saw Phillips weight loss intersection to pay the electricity bill Junction is junction with Soda Green fly on the plane to see the place is the leader see Felix Minus         Fat Junction intersection is junction with Soda Green on the plane to see the place is the leader saw Phillips weight loss intersection intersection is the intersection is considering the liberation of the road to go to sleep crazy fast Christmas intersection four quarter Phillips jiangdong elders acceptable kai-Fu Lee is the departure of the plane lost link fast decline Fat Soracá Click the law exam Big Brother-in-iaw drool of weight loss two mobile phone to kill two mobile phone fee intersection sleeping Frank pay the water and electricity intersection is to leave the plane to see click</Div>    <Divclass= "Switch"><spanID= "BTN2"></span></Div></Div>

Download

jquery Text Folding

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.