Skip to content

Instantly share code, notes, and snippets.

@biovisualize
Created July 10, 2012 20:04
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 biovisualize/3085882 to your computer and use it in GitHub Desktop.
Save biovisualize/3085882 to your computer and use it in GitHub Desktop.
Checkbox in foreignObject
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js"></script>
</head>
<body>
<script type="text/javascript">
var svg = d3.select("body").append("svg")
.attr("width", 100)
.attr("height", 100);
svg.append("foreignObject")
.attr("width", 100)
.attr("height", 100)
.append("xhtml:body")
.html("<form><input type=checkbox id=check /></form>")
.on("click", function(d, i){
console.log(svg.select("#check").node().checked);
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment