Skip to content

Instantly share code, notes, and snippets.

@bentinata
Created August 5, 2014 03:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bentinata/9642e6a25b9365a57016 to your computer and use it in GitHub Desktop.
Save bentinata/9642e6a25b9365a57016 to your computer and use it in GitHub Desktop.
<html>
<head>
<meta charset="UTF-8">
<title>Decomposition</title>
<style>
body
{
background-color: black;
}
#Position
{
top: 500px;
left: 500px;
right: 500px;
bottom: 500px;
position: relative;
color: white;
}
</style>
</head>
<body>
<div id="Position">
<img id="image" src="http://www.rsg-shop.com/images/Ball-PASTORELLI-Giallo-Fluo-00014-0.jpg" width="50px" height="50px">
<p id="text">Yellow!!</p>
</div>
<div id="Position">
<button onclick="f01()" type="button">Change</button>
<button onclick="f02()" type="button">Change Word</button>
<button onclick="f03()" type="button">Change Image</button>
</div>
<script>
function f01()
{
var img01 = document.getElementById("image").src;
var text01 = document.getElementById("text").innerHTML;
if (img01.match("rsg-shop"))
{
img01 = "http://www.precisionballs.com/solid_works/JPEG/ball.jpg";
text01 = "Blue!!";
}
else
{
img01 = "http://www.rsg-shop.com/images/Ball-PASTORELLI-Giallo-Fluo-00014-0.jpg";
text01 = "Yellow!!";
}
}
function f02()
{
if (text01.match("Yellow"))
{
text01 = "Blue";
}
else
{
text01 = "Yellow";
}
}
function f03()
{
if (img01.match("rsg-shop"))
{
img01 = "http://www.precisionballs.com/solid_works/JPEG/ball.jpg";
}
else
{
img01 = "http://www.rsg-shop.com/images/Ball-PASTORELLI-Giallo-Fluo-00014-0.jpg";
}
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment