GetTriggerUnit-
DogEntrepreneur
- Reaction score
- 129
Hi!
I was bored this afternoon and decided to work a bit of Javascript. Here's was I did!
Test it out on my future website! www.sc2tools.tk
Test.html
Spoiler.js
If you need it, use, modify it! It the function Spoiler() takes two params. but is the button name to change "Show"/"Hide" and div is what thing to show/hide.
I was bored this afternoon and decided to work a bit of Javascript. Here's was I did!
Test it out on my future website! www.sc2tools.tk
Test.html
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Title</title>
<script type="text/javascript" language="Javascript" src="spoiler.js"/>
</head>
<body>
<!-- The Show/Hide button -->
<input id="button1" type="button" value="Show" onclick="Spoiler('button1', 'div1')" />
<!-- What will be visible/hidden -->
<div id="div1" style="visibility:hidden;border:2px black solid;">
<!-- Inside the spoiler -->
Some Text<br/>
<span style="color:blue;">Some Coloured Text</span><br/>
</div>
</body>
</html>
Spoiler.js
Code:
function Spoiler(but, div) {
var state = document.getElementById(div).style.visibility;
if (state == "visible") {
document.getElementById(div).style.visibility = "hidden";
document.getElementById(but).value = "Show";
}
else {
document.getElementById(div).style.visibility = "visible";
document.getElementById(but).value = "Hide";
}
}
If you need it, use, modify it! It the function Spoiler() takes two params. but is the button name to change "Show"/"Hide" and div is what thing to show/hide.