Newbie_小白
没有都对的别人,也没有全错的自己,至少要有自己的坚持,无关他人、无关外物!

html:

 

<!DOCTYPE >
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<style type="text/css">
* {
margin: 10px;
padding: 0;
font-family: "微软雅黑", "arial", " sans-serif";
}

#div {
width: 200px;
height: 200px;
border: 1px red solid;
}

.test {
background: #76DBA3;
}
</style>
<script type="text/javascript" src="js/jquery-2.2.2.min.js">
</script>

<script type="text/javascript">
$(function () {
$("<div>", {
text: "这是动态创建的页面元素",
id: "div",
click: function () {
$(this).toggleClass("test");
}
}).appendTo("body");
})
</script>
</head>

<body>

</body>

</html>

 

result:

运行:

posted on 2016-05-15 17:56  Newbie_小白  阅读(198)  评论(0)    收藏  举报