Created
July 13, 2020 21:03
-
-
Save orbitmechanic/27bf8b8d591cbdbcc61beabc5fdff64f to your computer and use it in GitHub Desktop.
Using jQuery to enable a title hide/unhide button
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<header> | |
<!-- Load jQuery --> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"> </script> | |
</header> | |
<body> | |
<!-- Define Buttons --> | |
<button type="button" | |
onclick= '$("h1").slice(0,10).hide()' >HideH1's</button> | |
<button type="button" | |
onclick= '$("h1").slice(0,10).show()' >UnHideH1's</button> | |
<!-- Mock data --> | |
<h1>This is the first h1</h1> | |
<h2>This is the first h2</h2> | |
<p>Blabitty blah</p> | |
<h1>This is the second h1</h1> | |
<h2>This is the second h2</h2> | |
<p> Yakkity Yack. </p> | |
<h1>This is the third h1</h1> | |
<h2>This is the third h2</h2> | |
<h1>This is the fourth h1</h1> | |
<h1>This is the fifth h1</h1> | |
<h1>This is the sixth h1</h1> | |
<h1>This is the seventh h1</h1> | |
<h1>This is the eigth h1</h1> | |
<h1>This is the ninth h1</h1> | |
<h1>This is the tenth h1</h1> | |
<h1>This is the eleventh h1</h1> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment