In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly shows you "javascript how to hide text", the content is easy to understand, clear, hope to help you solve doubts, the following let the editor lead you to study and learn "javascript how to hide text" this article.
Javascript hidden text method: 1, create a HTML sample file; 2, set text content through div; 3, through the "function init () {...}" method to achieve hidden text function.
This article operating environment: windows7 system, javascript1.8.5 version, Dell G3 computer.
How does javascript hide text?
Text hiding based on javascript
Html code
Untitled document function init () {var len = 14; / / the default number of words displayed is var ctn = document.getElementById ("content"); / / get div object var content = CTN [XSS _ clean]; / / get the content in div / / alert (content); var span = document.createElement ("span") / / create the element var a = document.createElement ("a"); / / create the element span [XSS _ clean] = content.substring (0Llen); / / create the first len character a [XSS _ clean] = content.length > len of content in span? "
Expand ":"; / / set the display of an a.href = "_ javascript:void (0)"; a.onclick = function () {if (a [XSS _ clean] .indexOf ("expand") > 0) {/ / if a contains "expand", display "fold" a [XSS _ clean] = "
Put away "; Span [XSS _ clean] = content;} else {a [XSS _ clean] ="
Expand "; span [XSS _ clean] = content.substring (0Llen);}} / / set the div content to be empty, and the span element an element is added to the div [XSS _ clean] ="; ctn.appendChild (span); ctn.appendChild (a);}
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.