d3js 获取元素以及设置属性

DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>D3JS 获取元素以及添加属性title>
head>
<body>
    <p>Hello World 1p>
    <p>Hello World 2p>
    <script src="https://cdn.bootcss.com/d3/4.13.0/d3.min.js" charset="utf-8">script>
    <script type="text/javascript">
        d3.select("body").selectAll("p").text("mfg").style("color","red"); 
    script>
body>
html>

 说明:

var p1 = body.select("p");

p1.style("color","red");
是选择第一个p

 

转载于:https://www.cnblogs.com/mengfangui/p/9023368.html

你可能感兴趣的:(d3js 获取元素以及设置属性)