Skip to content

Instantly share code, notes, and snippets.

@larskotthoff
Forked from nvcleemp/index.html
Last active August 29, 2015 14:10
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 larskotthoff/f1a023777d7fa4439290 to your computer and use it in GitHub Desktop.
Save larskotthoff/f1a023777d7fa4439290 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<style>
div .tests {
float: none;
margin:auto;
text-align: center;
font: 20px sans-serif;
font-weight: bold;
display: table;
width: 100%;
}
.testlink {
color: #000;
text-decoration: none;
}
div .test {
display: table-cell;
width: 33.3333%;
text-align: center;
}​
</style>
</head>
<body>
<div class="tests">
<div class="test"><a href="#" class="testlink" id="test1" onclick="showTest1()">test 1</a></div>
<div class="test"><a href="#" class="testlink" id="test2" onclick="showTest2()">test 2</a></div>
</div>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script>
var selectedColor = "#9467bd";
var notSelectedColor = "#ffffff";
d3.select("#test1").style("background", notSelectedColor);
d3.select("#test2").style("background", notSelectedColor);
function showTest1(){
d3.select("#test1").transition().duration(2000).style("background", selectedColor);
d3.select("#test2").transition().duration(2000).style("background", notSelectedColor);
}
function showTest2(){
d3.select("#test1").transition().duration(2000).style("background", notSelectedColor);
d3.select("#test2").transition().duration(2000).style("background", selectedColor);
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment