Built with blockbuilder.org
| <!DOCTYPE html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script> | |
| <style> | |
| body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; } | |
| svg { width:100%; height: 100% } | |
| </style> | |
| </head> | |
| <body> | |
| <button id="showhide" onclick()>Click me</button> | |
| <script type="text/javascript"> | |
| var w = 300, h = 300; | |
| var color = 1; | |
| var svg = d3.select("body") | |
| .append("svg") | |
| .attr("width", w) | |
| .attr("height", h); | |
| d3.select("#showhide").on("click", function(){ | |
| color = color + 1; | |
| if (color % 2) | |
| { | |
| d3.select(this).text("Click me"); | |
| //Add other code below here | |
| } | |
| else | |
| { | |
| d3.select(this).text("Reset"); | |
| //Add other code below here | |
| } | |
| }); | |
| </script> | |
| </body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment