4 examples of 'toggle text' in JavaScript

Every line of 'toggle text' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
17function Toggle(tt) {
18 var el = document.getElementById(tt);
19 if (el.style.display == "block") {
20 el.style.display = "none";
21 }
22 else {
23 el.style.display = "block";
24 }
25}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

10function toggle(toggleId)
11{
12 var toggle = document.getElementById ? document.getElementById(toggleId) : document.all[toggleId];
13 toggle.textContent = toggle.innerHTML == '\u25b6' ? '\u25bc' : '\u25b6';
14}
45function toggle() {
46 var list = document.getElementsByClassName("gwt-TextArea");
47 var button = document.getElementById("hide-console");
48 var console = list[0];
49 if (console.style.display == "block") {
50 console.style.display = "none";
51 console.scrollTop = 99999;
52 button.innerHTML = "show console";
53 } else {
54 console.style.display = "block";
55 console.scrollTop = 99999;
56 button.innerHTML = "hide console";
57 }
58}
20function toggle(it){
21 var e = document.getElementById(it);
22 var s = e.style.visibility;
23 var vis = (s == "hidden") ? "visible" : "hidden";
24 document.getElementById(it).style.visibility = vis;
25}

Related snippets