10 examples of 'css show hide div on click' in JavaScript

Every line of 'css show hide div on click' 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
158function hideDiv(div) {
159 var pdiv = "#" + div,
160 button = pdiv + "-toggle"
161
162 if ($(pdiv).css('display') == 'none') {
163 $(pdiv).toggle('slow');
164 $(button).html('Hide');
165 }
166 else {
167 $(pdiv).toggle('slow');
168 $(button).html('Show');
169 }
170}
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}
54function hideDiv(div) {
55 $(div).hide();
56}
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 }
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}
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}
33function hideDiv(target, cb) {
34 $(target).hide(700, cb)
35}
137function hideDiv(id) {
138 jQuery('#' + id).hide();
139}
145function show_hide(id) {
146 jQuery('#' + id).toggle();
147}
31function hide_div(id){
32 $(id).hide('slow');
33}

Related snippets