This article mainly introduces more information about text Hiding Based on JavaScript. If you need more information, refer to this article to share with you the function of hiding more than some text. The code is relatively simple, if you are interested, refer to the following code.
The Code is as follows:
Hide text after exceeding the limitPrior to the Oscar Awards, dickaprio won the Best Leading Actor Award from the British Film and Television Art Institute (BAFTA) this year. This award is considered a prelude to the Oscar Award. Although he has been nominated for three times and fans have never been unfair to him, dickapio has not yet won an Oscar.
Prior to the Oscar Awards, dickaprio won the Best Leading Actor Award from the British Film and Television Art Institute (BAFTA) this year. This award is considered a prelude to the Oscar Award. Although he has been nominated for three times and fans have never been unfair to him, dickapio has not yet won an Oscar. However, dikaprio has not yet won an Oscar. However, dikaprio has not yet won an Oscar.
Script // obtains elements based on the class name. In this case, the element name must be obtained using the class to control the string degrees of multiple elements (text, text1. function getByClass (oParent, sClass) {if (oParent. getElementsByClassName) {return oParent. getElementsByClassName (sClass);} else {// IE 8 7 6var arr = []; var reg = new RegExp ('\ B' + sClass + '\ B '); var aEle = oParent. getElementsByTagName ('*'); for (var I = 0; I <aEle. length; I ++) {if (reg. test (aEle [I]. className) {arr. push (aEle [I]) ;}} return arr ;}} function testAuto () {var textName = getByClass (document, 'text'); for (var I = 0; I <textName. length; I ++) {var nowLeng = textName [I]. innerHTML. length; if (nowLeng> 85) {var nowWord = textName [I]. innerHTML. substr (0, 85) + '...'; textName [I]. innerHTML = nowWord; }}testauto (); script
The above code is simple to implement the function of hiding more than a part of the text. I hope you will like it.