Created
September 4, 2019 15:28
Accediendo a los valores de un radio button desde d3js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>Accediendo a los valores de un radio button</title> | |
<script src="https://d3js.org/d3.v5.min.js"></script> | |
</head> | |
<body> | |
<div> | |
<label for="male">Male</label> | |
<input checked type="radio" name="gender" id="male" value="male"><br> | |
<label for="female">Female</label> | |
<input type="radio" name="gender" id="female" value="female"><br> | |
<label for="other">Other</label> | |
<input type="radio" name="gender" id="other" value="other"><br><br> | |
</div> | |
<script> | |
// si queres saber, cual es el valor seleccionado, podes usar esto: | |
console.log( d3.select('input[name="gender"]:checked').property("value") ); | |
d3.selectAll('input[type="radio"]').on("change",function(d){ | |
console.log( this.value ); | |
}) | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment