如果你的remove掉的话 页面上已经没有了 得自己重新创建 本着你要想继续用这个标签建议不要remove掉hide隐藏掉就可以了

解决方案 »

  1.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
    <script type="text/javascript">
    $(document).ready(function(){

       $(".div_btn").click(function(){
       $(this).(".div_c").show();
       $(this).hide();
       })
       $(".div_c").click(function(){
       $(".div_btn").show();
       $(this).hide();
       })
    });
    </script>
    <style type="text/css">
    *{
    margin:0;
    padding:0;
    }
    .div{
    width:300px;
    height:200px;
    border:1px solid #DCDCDC;
    float:left;
    position:relative;
    }
    .div_btn{
    width:70px;
    height:30px;
    background:#00BCF3;
    float:right;
    margin:150px 20px 0 0;
    line-height:30px;
    text-align:center;
    color:#FFF;
    }
    .div_c{
    width:70px;
    height:30px;
    background:#00BCF3;
    position:absolute;
    top:10px;
    right:10px;
    display:none;
    }
    </style>
    </head><body>
    <div class="div">
    <a href="javascript:;" class="div_c">点击</a>
    <a href="javascript:;" class="div_btn">点击</a>
    </div>
    <div class="div">
    <a href="javascript:;" class="div_c">点击</a>
    <a href="javascript:;" class="div_btn">点击</a>
    </div>
    <div class="div">
    <a href="javascript:;" class="div_c">点击</a>
    <a href="javascript:;" class="div_btn">点击</a>
    </div></body>
    </html>
    请问下 我现在都改成隐藏的了
    这些问题应该怎么解决啊 当我点击".div_btn"的时候 创建了".div_c"  当点击创建".div_c" 还原".div_btn" 
    还有就是在点击其他的".div_btn"的时候 已经创建了的".div_c" 也要还原回去请问下 应该怎么做啊  
      

  2.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
    <script type="text/javascript">
    $(document).ready(function() {
    var cj = "<a class='div_c'></a>";
    $(".div_btn").each(function() {
    var o = $(this);
    var p = o.closest('div'); p.click(function(e) {
    var t = e.target;
    var flag = false;
    var newb;
    if (t.className.indexOf('div_btn') !== -1) {
    if (!flag) {
    newb = $(cj);
    newb.appendTo(p);
    o.hide();
    flag = true;
    } else {
    newb.show();
    o.hide();
    }
    } else if (t.className.indexOf('div_c') !== -1) {
    $(t).hide();
    o.show();
    } })
    }) });
    </script>
    <style type="text/css">
    * {
    margin: 0;
    padding: 0;
    }.div {
    width: 300px;
    height: 200px;
    border: 1px solid #DCDCDC;
    float: left;
    position: relative;
    }.div_btn {
    width: 70px;
    height: 30px;
    background: #00BCF3;
    float: right;
    margin: 150px 20px 0 0;
    line-height: 30px;
    text-align: center;
    color: #FFF;
    }.div_c {
    width: 70px;
    height: 30px;
    background: #00BCF3;
    position: absolute;
    top: 10px;
    right: 10px;
    }
    </style>
    </head><body>
    <div class="div"> <a href="javascript:;" class="div_btn">点击</a>
    </div>
    <div class="div"> <a href="javascript:;" class="div_btn">点击</a>
    </div>
    <div class="div"> <a href="javascript:;" class="div_btn">点击</a>
    </div></body>
    </html>
      

  3.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
    <script type="text/javascript">
    $(document).ready(function(){ var cj='<a onclick="javascript:hide(this);" class="div_c" href="#">点击</a>';
       $(".div_btn").each(function(){
               $(this).click(function(){
       
                   $(this).closest('div').append(cj);
                   
                   $(this).closest('div').siblings('.div').find(".div_c:visible").remove();
                   $(this).closest('div').siblings('.div').find(".div_btn:hidden").show();
                   $(this).hide();
               })
        })
     
    });
    function hide(obj){
    $(obj).siblings('.div_btn').show();
    $(obj).remove();
    }
    </script>
    <style type="text/css">
    *{
    margin:0;
    padding:0;
    }
    .div{
    width:300px;
    height:200px;
    border:1px solid #DCDCDC;
    float:left;
    position:relative;
    }
    .div_btn{
    width:70px;
    height:30px;
    background:#00BCF3;
    float:right;
    margin:150px 20px 0 0;
    line-height:30px;
    text-align:center;
    color:#FFF;
    }
    .div_c{
    width:70px;
    height:30px;
    background:#00BCF3;
    position:absolute;
    top:10px;
    right:10px;
    }
    </style>
    </head><body>
    <div class="div"> <a href="javascript:;" class="div_btn">点击</a>
    </div>
    <div class="div">

    <a href="javascript:;" class="div_btn">点击</a>
    </div>
    <div class="div">

    <a href="javascript:;" class="div_btn">点击</a>
    </div></body>
    </html>
      

  4.   

    该一下
    $(document).ready(function() {
            var cj = "<a class='div_c'></a>";
            $(".div_btn").each(function() {
                var o = $(this);
                var p = o.closest('div');
    var flag = false;
    var newb;
     
                p.click(function(e) {
                    var t = e.target;
                    
                    
                    if (t.className.indexOf('div_btn') !== -1) {
                        if (!flag) {
                            newb = $(cj);
                            newb.appendTo(p);
                            o.hide();
                            flag = true;
                        } else {
                            newb.show();
                            o.hide();
                        }
                    } else if (t.className.indexOf('div_c') !== -1) {
                        $(t).hide();
                        o.show();
                    }
     
                })
            })
     
        });