| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2206 人关注过本帖
标题:怎么设置新生成div的宽度,点击第二次添加后自动换到下行显示
只看楼主 加入收藏
lzy740744969
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2016-12-29
收藏
 问题点数:0 回复次数:1 
怎么设置新生成div的宽度,点击第二次添加后自动换到下行显示
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.
<html xmlns="http://www.
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>录入表格</title>
<style>

#myDiv{
    width:100px;
    height:50px;
    background-color:#ccc;
    }

</style>
<script>

</script>

</head>

<body>
<input type="text" id="text01" name="what"  style="width:100px"/>
<input type="text" id="text02" name="where"/>
<input type="button" id='B' name="plus" value="添加" onclick="plus()"/>
<hr>
<div id=myDiv ><p></p></div>



<script type="text/javaScript">
function plus() {
        var newdiv1 = document.createElement("div");     //创建div
        newdiv1.style.width = "50";        // 设置宽度
         newdiv1.style.height ="10";
        var textnode = text01.value+"\n";
        newdiv1.innerHTML = textnode;    //给新div添加内容text01
        //newdiv1.style.width=100+"px";
        document.getElementById("myDiv").appendChild(newdiv1);    //把div插入到最后
   
        
        var newdiv2 = document.createElement("div");
        newdiv2.style.width = "50";        // 设置宽度
         newdiv2.style.height ="10";
        var textnode = text02.value+"\n";
        newdiv2.innerHTML = textnode;
        newdiv1.appendChild(newdiv2);
        
}
</script>


</body>
</html>
搜索更多相关主题的帖子: content PUBLIC style title 
2016-12-29 10:21
lzy740744969
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2016-12-29
收藏
得分:0 
2016-12-29 11:11
快速回复:怎么设置新生成div的宽度,点击第二次添加后自动换到下行显示
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016808 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved