<!DOCTYPE HTML><HTML><HeadLang= "en"> <MetaCharSet= "UTF-8"> <title>Text is hidden after a limited number of words</title> <style>. Text{width:800px;Height:48px;Line-height:24px;Color:#333;background:#ccc;Border:#eaeaea 1px solid;margin:40px Auto; }. Text1{width:500px;Height:72px; } </style></Head><Body><Divclass= "text">Before the Academy Awards, DiCaprio won the Best Actor award at the British Academy of Film and Television Arts (BAFTA) this year. The award is considered a prelude to the Academy Awards. Although he has been nominated for three times, fans have been grievances for him, but DiCaprio has not won an Oscar yet.</Div><Divclass= "Text Text1">Before the Academy Awards, DiCaprio won the Best Actor award at the British Academy of Film and Television Arts (BAFTA) this year. The award is considered a prelude to the Academy Awards. Although he has been nominated for three times, fans have been grievances for him, but DiCaprio has not won an Oscar yet. But DiCaprio has not won an Academy Award yet. But DiCaprio has not won an Academy Award yet.</Div><Script> //gets the element according to the class name, in this case the reason is to get the element name with class, in order to control the string degree of multiple elements (TEXT,TEXT1). functionGetbyclass (oparent, sclass) {if(oparent.getelementsbyclassname) {returnOparent.getelementsbyclassname (Sclass); } Else { //IE 8 7 6 vararr= []; varReg= NewRegExp ('\\b' +Sclass+ '\\b'); varAele=Oparent.getelementsbytagname ('*'); for (varI= 0; I<aele.length; I++) { if(Reg.test (aele[i].classname)) {Arr.push (aele[i]); } } returnarr; } } functionTestauto () {varTextname=Getbyclass (document,'text'); for (varI= 0; I<textname.length; I++) { varNowleng=textname[i].innerhtml.length; if(Nowleng> - ) { varNowword=Textname[i].innerhtml.substr (0, -) + '······'; Textname[i].innerhtml=Nowword; }}} Testauto ();</Script></Body></HTML>
Text is hidden after a limited number of words