慕设计8083804
2019-07-27 15:59
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus®">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<title>Document</title>
<style type="text/css">
.message{
width:200px;
height:100px;
background-color:#CCC;}
</style>
</head>
<body>
<script type="text/javascript">
var newp=document.createElement("p");
newp.className="message";
var newText=document.createTextNode("I love JavaScript!").value;
newp.innerHTML=newText;
document.body.appendChild(newp);
</script>
</body>
</html>
value代表的是该标签的属性,不等同于它的文本内容
JavaScript进阶篇
468061 学习 · 21891 问题
相似问题