如何设置添加新div的位置,同时单击按钮 [英] how to set the position for add the new div while click the button

查看:83
本文介绍了如何设置添加新div的位置,同时单击按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨朋友



i在点击添加按钮时添加了div而没有修复position.can任何一个帮助我。

 <   div     id   =  divContent    style   =  border:solid 3px grey; height:450px; width:100%; >  
< div id = divSubContent < span class =code-attribute> style = border:solid 1px grey;宽度:15%;高度:100%; >
< div id = divSubContent1 style = border:solid 1px grey;宽度:100%;高度:50px; >
& nbsp;
< / div >
< div id = divSubContent2 样式 = 边框:实心1px灰色;宽度:100%;高度:395像素; >
& nbsp;
< / div >
< / div >
< / div >







 $(document).ready(function (){
new_div =< div style =' border:solid 1px grey; width: 15%; ' > < div style =' border:solid 1px grey;高度:50px;' > & nbsp; < / div > < div style =' border:solid 1px grey;高度:395像素;' > & nbsp; < / div > < / div > ;
$(#aBAddClnBtn ).click(function(){

$(#divContent)。append(new_div);
// alert($(#divContent)。html()) ;
返回false;
});
});

解决方案

(文档)。 ready(function(){
new_div =< div style =' border:solid 1px grey;宽度:15%; ' > < div style =' border:solid 1px grey;高度:50px;' > & nbsp; < / div > < div style =' border:solid 1px grey;高度:395像素;' > & nbsp; < / div > < / div > ;


< blockquote>(#aBAddClnBtn)。click(function(){


(#divContent)。append(new_div);
// alert(


hi friends

i added div for while clicking the addbutton but not fixed the position.can any one help me.

<div id="divContent" style="border: solid 3px gray; height: 450px; width: 100%;">
                        <div id="divSubContent" style="border: solid 1px gray; width: 15%; height: 100%;">
                            <div id="divSubContent1" style="border: solid 1px gray; width: 100%; height: 50px;">
                                &nbsp;
                            </div>
                            <div id="divSubContent2" style="border: solid 1px gray; width: 100%; height: 395px;">
                                &nbsp;
                            </div>
                        </div>
                    </div>




$(document).ready(function() {
           new_div = "<div  style='border: solid 1px gray; width: 15%; '><div style='border: solid 1px gray; height: 50px;'>&nbsp;</div> <div  style='border: solid 1px gray; height: 395px;'>&nbsp;</div></div>";
           $("#aBAddClnBtn").click(function() {

               $("#divContent").append(new_div);
               //                alert($("#divContent").html());
               return false;
           });
       });

解决方案

(document).ready(function() { new_div = "<div style='border: solid 1px gray; width: 15%; '><div style='border: solid 1px gray; height: 50px;'>&nbsp;</div> <div style='border: solid 1px gray; height: 395px;'>&nbsp;</div></div>";


("#aBAddClnBtn").click(function() {


("#divContent").append(new_div); // alert(


这篇关于如何设置添加新div的位置,同时单击按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆