zl程序教程

您现在的位置是:首页 >  其它

当前栏目

[D3] Modify DOM Elements with D3 v4

with dom Elements v4 D3 modify
2023-09-14 09:00:51 时间

Once you can get hold of DOM elements you’re ready to start changing them. Whether it’s changing colors, labels, or even link destinations, this lesson demonstrates the process and patterns for updating the DOM using D3’s powerful APIs.

 

// you will see two red links when viewing this on Plunker
// we did not see this behavior in the lesson video
// because our BrowserSync dev server was inserting a script
// making the last link NOT a second child

d3.selectAll('a:nth-child(2)')
  .attr('href', 'http://google.com')
  .classed('red', true)
  .html('Inventory <b>SALE</b>');