10 examples of 'jquery show hide div onclick example' in JavaScript

Every line of 'jquery show hide div onclick example' 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
115function ShowHide (divName, show)
116{
117 var div = document.getElementById (divName);
118 if (show) {
119 div.style.display = 'block';
120 } else {
121 div.style.display = 'none';
122 }
123}
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

145function show_hide(id) {
146 jQuery('#' + id).toggle();
147}
28function showhide(div) {
29 if ( document.getElementById(div).style.display == 'block') {
30 document.getElementById(div).style.display = 'none';
31 }
32 else {
33 document.getElementById(div).style.display = 'block';
34 }
35 }
34function showHideDiv(id) {
35 var spanElement = document.getElementById('span_' + id);
36 var arrowElement = document.getElementById('arrow_' + id);
37 if (spanElement.style.display == 'block' || spanElement.style.display == '') {
38 spanElement.style.display = 'none';
39 arrowElement.className = 'right_arrow';
40 } else {
41 spanElement.style.display = 'block';
42 arrowElement.className = 'down_arrow';
43 }
44}
32function showHideDiv(id) {
33 var div = document.getElementById(id);
34 if ( div ) {
35 if ( div.style.display != "none" ) {
36 div.style.display = "none";
37 } else {
38 div.style.display = "";
39 }
40 }
41}
137function hideDiv(id) {
138 jQuery('#' + id).hide();
139}
31function hide_div(id){
32 $(id).hide('slow');
33}
54function hideDiv(div) {
55 $(div).hide();
56}
17function showhide(divID) {
18 var item = document.getElementById(divID);
19 if (item) {
20 item.className=(item.className=='elaborateHidden')?'elaborateShown':'elaborateHidden';
21 }
22}
130function showHide(divId) {
131 let elmt = document.getElementById(divId);
132 // let status = elmt.style.display;
133 // elmt.style.display = (status === 'none' ? 'inline' : 'none');
134 let h = elmt.style.height;
135 let newH = '', newV = '', newO = '';
136 if (h === '' || h === '0' || h === '0px') {
137 newH = '100%';
138 newV = 'visible';
139 newO = '1';
140 } else {
141 newH = '0';
142 newV = 'hidden';
143 newO = '0';
144 }
145 elmt.style.height = newH;
146 elmt.style.visibility = newV;
147 elmt.style.opacity = newO;
148}

Related snippets