| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26-27--28 29---30 31--32 33 34 35 36 37 38-39 40 41 42 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
<script language= "javascript" src= "Jquery.js" ></script> <script language= "JavaScript" > var cur_ Status = "Less"; $.extend ({show_more_init:function () {//alert ("show_more_init!"); var charnumbers=$ (". Content"). html (). length;// Total words var limit=100;//display words if (charnumbers>limit) {var orgtext=$ (". Content"). HTML ()//Original text var orgheight=$ (". Content" ). Height ();//original height var showtext=orgtext.substring (0,limit);//finally displayed text $ (". Content"). html (showtext); var contentheight=$ (". Content"). Height ()//(". Switch") after intercepting the content. Click (function () {if (Cur_status = = "Less") {$. Content "). Height (contentheight). HTML (orgtext). Animate ({Height:orgheight}, {duration:" slow "}); $ (this). HTML ("shrink"); Cur_status = "more"; }else{$ (". Content"). Height (orgheight). HTML (showtext). Animate ({Height:contentheight}, {duration: "fast"}); $ (This) . html ("expand"); Cur_status = "less"; } } ); } else {$ (". Switch"). Hide ();} }); $ (document). Ready (function () {$.show_more_init ();}); </script> <! DOCTYPE html> <html> <head> <meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/> <title>test</title> <style> #limittext {width:640px; height:auto; position: relative; Background-color: #ccc; Color:black; }. switch{font-size:12px; text-align:center; cursor:pointer; font-family:verdana; font-weight:800; position:absolute ; bottom:0; width:100%; /*background:url (more-bg.png) repeat-x bottom;*/height:40px; line-height:80px; } </style> </head> <body> <div id= "Limittext" > <div class= "Content" style= "Padding-bottom : 15px; " > It's a long piece of text, it's a long piece of text, it's a long piece of text, it's a long piece of text, it's a long piece of text, it's a long piece of text, it's a long piece of text, it's a long piece of text, it's a long piece of text, It's a long piece of text, it's a long piece of text, it's a long paragraph of text, it's a long paragraph of text, it's a long piece of text, it's a long piece of text, it's a long piece of text, it's a long piece of text, it's a long piece of text, it's a long piece of text, It's a long piece of text, it's a long piece of text, it's a long paragraph of text, it's a long paragraph of text, it's a long piece of text, it's a long piece of text, it's a long piece of text, it's a long piece of text, it's a long piece of text, it's a long piece of text, It was a long paragraph of text, and it was a long piece of text, this is a long piece of text, it is a long paragraph of text, it is a long paragraph of text, it is a long paragraph of text, it is a long paragraph of text, it is a long piece of writingWord, which was a long piece of text, which was a long paragraph of text, which was a long paragraph of text, it's a long piece of text, it's a long piece of text, it's a long piece of text, it's a long piece of text, it's a long piece of text, it's a long piece of text, It's a long piece of text, it's a long piece of text, it's a long paragraph of text, it's a long paragraph of text, it's a long piece of text, it's a long piece of text, it's a long piece of text, it's a long piece of text, it's a long piece of text, it's a long piece of text, It's a long piece of text, it's a long piece of text, it's a long paragraph of text, it's a long paragraph of text, it's a long piece of text, it's a long piece of text, it's a long piece of text, it's a long piece of text, it's a long piece of text, it's a long piece of text, It's a long piece of text, it's a long piece of text, it's a long paragraph of text, it's a long paragraph of text, it's a long piece of text, it's a long piece of text, it's a long piece of text, it's a long piece of text, it's a long piece of text, it's a long piece of text, It's a long piece of text, it's a long piece of text, it's a long paragraph of text, it's a long paragraph of text, it's a long piece of text, it's a long piece of text, it's a long piece of text, it's a long piece of text, it's a long piece of text, it's a long piece of text, It's a long piece of text, it's a long piece of text, it's a long paragraph of text, it's a long paragraph of text, it's a long piece of text, it's a long piece of text, it's a long piece of text, it's a long piece of text, it's a long piece of text, it's a long piece of text, It's a long piece of text, it's a long piece of text </div> <div class= "switch" > Expand </div> </div> </body> </html> |