I am trying to change the value of my progress bar.
var progressBar = d3.select("#current").append("input")
.attr("class","loading")
.attr("data-width","135")
.attr("value","0");
When I do this :
progressBar.select("input").attr("value","5");
The value is not changed. What should I do ?
The problem with your code is that you already selected your input and bound it to the variable progressBar. So this piece of code you showed:
progressBar.select("input").attr("value", "5")
Effectively means:
d3.select("#current").select("input").select("input").attr("value", "5")
You're essentially selecting for an input within the input you created which doesn't exist.
Your code should work fine by simply using:
progressBar.attr('value', 5)
Try
var progressBar = d3.select("#current").append("input")
.attr("class","loading")
.attr("data-width","135")
.val(0);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.