Skip to content

Commit

Permalink
Update Javascript toggle visibility.html
Browse files Browse the repository at this point in the history
  • Loading branch information
lwindolf authored Dec 11, 2020
1 parent 6e13e59 commit 110dc47
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions examples/Javascript Examples/Javascript toggle visibility.html
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
Toggling visibility of elements is best done in jQuery like this. It is important to recursively show to avoid children staying invisible.

<pre>
&lt;script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js">&lt;/script>
&lt;script>
google.load('jquery', '1.3.1');
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
<script>
google.load('jquery', '1.3.1');

function toggleVisibility(id) {
if($(id).is(":visible")) {
$(id).hide();
} else {
$(id)
.show()
.children().show();
}
}
</script>

function toggleVisibility(id) {
if($(id).is(":visible")) {
$(id).hide();
} else {
$(id)
.show()
.children().show();
}
}
&lt;/script>
</pre>

0 comments on commit 110dc47

Please sign in to comment.