【技术】动态创建div
点击前
点击后
html部分:
<body>
</body>
css部分:
.test1{
color: red;
cursor: pointer;
}
.test2{
color: blue;
}
js部分:
$(function() {
$("<div>", {
"class": "test1",
text: "Click me!",
click: function(){
$(this).toggleClass("test2");
}
}).appendTo("body");
});

浙公网安备 33010602011771号