javascript - How to update the contents of a text input with d3? -
I am trying to create text input controls in D3 for which the data needs to be covered in text input. I
d3.selectAll ('# textfield'). Data ([number]) .attr ('value', function (d) {return d}). But once editing the text After doing it it has no use and then tries to update external
Update:
I have found:
var node = D3.selectAll ('# textfield'). Data ([number]) .node () node.value = number But I'm not sure whether this is the correct approach or any clue?
You have the value of setting value And value is just a special feature that comes in the setAttribute function (which is used to set an attribute internally to D3 ) is) . This approach is not much better, but more practical use of D3 : d3.selectAll ('# textfield') Data ([number]) .each (function (d) {this.value = d;}); Demo:
In addition to this, no one (and perhaps should ) do not use plain JS to do this , Unless you have no compelling arguments against it, the use of D3 can only be overworked: document.getElementById ('textfield'). Value = number;
Comments
Post a Comment