- html中输出hello world
<html>
<head>
<meta charset="utf-8">
<title>HelloWorld</title>
</head>
<body>
<p>Hello World 1</p>
<p>Hello World 2</p>
</body>
</html>
2.JavaScript来更改hello world
<html>
<head>
<meta charset="utf-8">
<title>hello world</title>
</head>
<body>
<p>hello world 1</p>
<p>hollo world 2</p>
<script>
var ps=document.getElementsByTagName("p");
console.log(ps);
console.log(typeof(ps));
for(let i=0;i<ps.length;i++){
let p=ps[i];
p.innerHTML="I like dog "+i;
}
</script>
</body>
</html>
3、利用D3.js来更改hello world
<html>
<head>
<meta charset="utf-8">
<title>hello world</title>
</head>
<body>
<p>hello world 1</p>
<p>hollo world 2</p>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script>
d3.select("body").selectAll("p").text("I like the D3.js")
</script>
</body>
</html>
涉及到的两个概念
- 选择集
d3.select()或者d3.selectAll()返回的对象就是一个选择集 - 链式语法
D3能够不断的调用函数,JQuery也是类似的哦