<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<title></title>
<script src="js/mui.min.js"></script>
<link href="css/mui.min.css" rel="stylesheet" />
<style type="text/css">
.divsow{
background:#0062CC;
height: 20px;
margin-bottom: 5px;
}
</style>
</head>
<body>
<header class="mui-bar mui-bar-nav">
<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
<h1 class="mui-title">adddiv</h1>
</header>
<div class="mui-content" id="div1">
<button type="button" class="mui-btn mui-btn-blue" onclick="adddiv()">增加</button>
<div class="divsow">
</div>
</div>
<script type="text/javascript" charset="utf-8">
mui.init();
function adddiv() {
var i = 0;
for(;i<6;i++){
var para = document.createElement("div");
para.setAttribute("class","divsow");//为新增节点div,添加类名,获取当前的样式
var node=document.createTextNode(i);
para.appendChild(node);
var element = document.getElementById("div1");
element.appendChild(para);
}
}
</script>
</body>
</html>
tuchaofu
- 发布:2015-12-08 11:20
- 更新:2015-12-08 11:20
- 阅读:4544
新增DOM节点样式问题(解决方法:设置类样式,增加类名)参考代码如下
分类:MUI
3 个评论
要回复文章请先登录或注册
tuchaofu (作者)
唐糖
蔡繁荣