Skip to content

Instantly share code, notes, and snippets.

@s0ren
Last active August 29, 2015 14:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save s0ren/fb4e9ca1e7182f7c4915 to your computer and use it in GitHub Desktop.
Save s0ren/fb4e9ca1e7182f7c4915 to your computer and use it in GitHub Desktop.
GUI
<html>
<header>
<style>
#stickswrapper div img
{
display: inline;
}
#stickswrapper div img
{
border: 5px solid green;
}
#stickswrapper div:nth-child(2) img:nth-last-child(2)
{
border: 5px solid red;
}
#stickswrapper div:nth-child(2) img:nth-child(1)
{
border: 5px solid red;
}
#stickswrapper div img[src='stick.png']
{
border: 5px solid yellow;
}
#stickswrapper div img[style = 'display:inline']
{
border: 5px solid orange;
}
/*
#stickswrapper div:nth-child(2)
{
border: 5px solid red;
}
*/
</style>
</header>
<body>
<div id="stickswrapper">
<div id="row0">
<img src="stick.png" onClick="clickStick(event, 0)">
<img src="stick.png" onClick="clickStick(event, 0)">
<button onclick="clickRow(event, 0)">Fjern</button>
</div>
<div id="row1">
<img src="stick.png" onClick="clickStick(event, 1)">
<img src="stick.png" onClick="clickStick(event, 1)">
<img src="stick.png" onClick="clickStick(event, 1)" style="display: inline;">
<img src="stick.png" onClick="clickStick(event, 1)">
<button onclick="clickRow(event, 1)">Fjern</button>
</div>
</div>
<script type="text/javascript">
var currentRow = null;
function clickRow(event, row)
{
if (currentRow === null)
{
currentRow = row;
}
if(row === currentRow)
{
var billede = document.querySelector("#stickswrapper div:nth-child("
+ (row+1) + ") img");
billede.parentNode.removeChild(billede);
}
}
function clickStick(event, row)
{
if (currentRow === null)
{
currentRow = row;
}
if(row === currentRow)
{
event.currentTarget.style.display = "none";
//this.style.display = "none";
// var billede = document.querySelector("#stickswrapper div:nth-child(" + (row+1) + ") img:last-child");
// billede.style.display = "none";
}
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment