尝试用函数调用的方法,但是p元素创建不出来?
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<style type="text/css">
.message{
width:200px;
height:100px;
background-color:#ccc;
}
</style>
</head>
<body>
<script type="text/javascript">
var main=document.body;
function createa(classn,aa){
var x=document.createElement("p");
x.setAttribute(class,classn);
var y=document.createTextNode(aa);
main.appendChild(x);
x.appendChild(y);
}
main.createa("message","I love javascript");
</script>
</body>
</html>