本帖最后由 oicq362934348 于 2014-09-05 17:08:57 编辑

解决方案 »

  1.   

    输入框的内容需要用Dom获取并输出吧?或者用JQuery $("").val()
      

  2.   


    function demo(){
    var p_text = $(".ck").html();
    document.write(p_text);
    }
      

  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=gb2312" />
    <title>行程编辑小助手(Yousc.com wujun Inc.)</title>
    <style type="text/css">
    em{ font-style: normal; }
    * {margin:0;padding:0;font-size:12px;list-style:none;border:0;}
    body{ margin:0px; padding:0px; background-color:#f0f0f0; font-family:Arial, Helvetica, sans-serif;}
    a{ text-decoration:none;}
    .top{ width:970px; height:30px; border-bottom:1px solid #dbdbdb; margin:0px auto;}
    .logo{ width:300px; height:30px; line-height:30px; float:left; font-size:14px; margin:0px 5px;}
    .clear{ display:block; height:0px; line-height:0px; font-size:0px; clear:both;}
    .shanchu{ width:14px; height:14px; margin:3px 17px; display:block; float:right; background:url(images/bg_mj.png) no-repeat 0px -661px; cursor:pointer;}
    .zj{ width:922px; height:22px; padding:10px 14px; font-size:12px;}
    .zj_an{ display:block; width:83px; height:22px; float:left; background:url(images/bg_mj.png) no-repeat 0px -695px; cursor:pointer;}
    .zj_ts{display:block; height:22px; float:left; color:#ff075b; line-height:22px; padding-left:10px;}
    .zj_input_a{float:right; margin:5px 5px 0px 0px; _margin:1px 1px 0px 0px;}
    .zj_bc{display:block; height:22px; float:right; line-height:22px; color:#555555;cursor:pointer;}
    .box{ width:950px; height:auto; margin:0px auto; border-top:1px solid #f9f9f9; padding:30px 10px;}
    .ck{ width:950px; height:auto; padding-top:10px;}
    .day_list{width:950px; height:55px; padding:10px 0px; color:#555555; font-size:12px; border-bottom:1px solid #dddddd;}
    .h2_title{height:22px; display:block; padding:0px 7px 0px 14px; line-height:22px; float:left;}
    .h2_title_a{ width:133px; height:20px; float:right; border:1px solid #bababa; padding:0px 2px; _height:17px; _padding:3px 2px 0px 2px; margin-left:4px;}
    .ctain{font-weight:bold;height:33px; display:block; padding:0px 5px 0px 0; line-height:22px; float:left;}
    .ctain li{font-weight:bold;height:22px; display:block; padding:0px 7px 0px 14px; line-height:22px; float:left;}
    .ctain_d{ width:520px; height:20px; float:right; border:1px solid #bababa; padding:0px 2px; _height:17px; _padding:3px 2px 0px 2px; margin:0px 36px 0px 6px;}
    .ctain_e{ width:95px; height:20px;border:1px solid #bababa; padding:0px 2px; _height:17px; _padding:3px 2px 0px 2px; margin:0px 36px 0px 6px;}
    </style>
    <script type="text/javascript" src="images/jquery-1.9.1.min.js"></script>
    <script type="text/javascript">
      $(document).ready(function(){
    $(".shanchu").click(function(){
      if ($(".day_list").size() > 1) { 
                  $(this).parent().remove(); 
                    } else {
                     $(".zj_ts").html("一个行程至少有1天"); 
                    } 
    });

    $(".zj_an").click(function(){
     $(".ck").append($(".day_list:first").clone(true));
     $(".zj_ts").html("");
    });
      });
        </script>
    </head>
    <body>
    <div class="top">
      <div class="logo">行程编辑小助手</div>
      <div class="clear"></div>
    </div>
    <div class="box">
      <div class="ck" id="ck">
        <div class="day_list">
          <h2 class="h2_title">第1天 &gt;&gt;<input name="" type="text" class="h2_title_a" id="num-a"/></h2>
          <p class="ctain">行程内容:<input name="" type="text" class="ctain_d" id="num-b"/></p>
          <ul class="ctain">
            <li><strong>用餐</strong> &nbsp;&nbsp;&nbsp;&nbsp;早餐:<input name="" type="text" class="ctain_e" id="num-c"/> 午餐:<input name="" type="text" class="ctain_e" id="num-d"/> 晚餐:<input name="" type="text" class="ctain_e"  id="num-e"/></li>
            <li><strong>住宿</strong> &nbsp;&nbsp;&nbsp;&nbsp;<input name="" type="text" class="h2_title_a" id="num-f"/></li>
          </ul>
          <span class="shanchu"></span>
        </div>
      </div>
      
      <div class="zj">
        <span class="zj_an"></span>
        <span class="zj_ts"></span>
        <span class="zj_bc" onclick="demo()">保存html代码</span>
        <span class="clear"></span>
      </div>
    </div>
    <script type="text/javascript">function demo(){
    var p_text = $(".ck").html();
    document.write(p_text);
    }
    function doCopy(obj){        var codeObj = document.getElementById(obj);        clipboardData.setData('text', codeObj.innerText);        alert('已经复制代码');    }</script>
    </body>
    </html>////demo() doCopy都是做的测试
      

  4.   

    增加input 的失焦事件onblur="tt(this)"
    function tt(t){
    $(t).attr('value',$(t).val());
    }然后复制就input就有值了,刚已经试过。
      

  5.   

    以下是全部代码:
    <!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=gb2312" />
    <title>行程编辑小助手(Yousc.com wujun Inc.)</title>
    <style type="text/css">
    em{ font-style: normal; }
    * {margin:0;padding:0;font-size:12px;list-style:none;border:0;}
    body{ margin:0px; padding:0px; background-color:#f0f0f0; font-family:Arial, Helvetica, sans-serif;}
    a{ text-decoration:none;}
    .top{ width:970px; height:30px; border-bottom:1px solid #dbdbdb; margin:0px auto;}
    .logo{ width:300px; height:30px; line-height:30px; float:left; font-size:14px; margin:0px 5px;}
    .clear{ display:block; height:0px; line-height:0px; font-size:0px; clear:both;}
    .shanchu{ width:14px; height:14px; margin:3px 17px; display:block; float:right; background:url(images/bg_mj.png) no-repeat 0px -661px; cursor:pointer;}
    .zj{ width:922px; height:22px; padding:10px 14px; font-size:12px;}
    .zj_an{ display:block; width:83px; height:22px; float:left; background:url(images/bg_mj.png) no-repeat 0px -695px; cursor:pointer;}
    .zj_ts{display:block; height:22px; float:left; color:#ff075b; line-height:22px; padding-left:10px;}
    .zj_input_a{float:right; margin:5px 5px 0px 0px; _margin:1px 1px 0px 0px;}
    .zj_bc{display:block; height:22px; float:right; line-height:22px; color:#555555;cursor:pointer;}
    .box{ width:950px; height:auto; margin:0px auto; border-top:1px solid #f9f9f9; padding:30px 10px;}
    .ck{ width:950px; height:auto; padding-top:10px;}
    .day_list{width:950px; height:55px; padding:10px 0px; color:#555555; font-size:12px; border-bottom:1px solid #dddddd;}
    .h2_title{height:22px; display:block; padding:0px 7px 0px 14px; line-height:22px; float:left;}
    .h2_title_a{ width:133px; height:20px; float:right; border:1px solid #bababa; padding:0px 2px; _height:17px; _padding:3px 2px 0px 2px; margin-left:4px;}
    .ctain{font-weight:bold;height:33px; display:block; padding:0px 5px 0px 0; line-height:22px; float:left;}
    .ctain li{font-weight:bold;height:22px; display:block; padding:0px 7px 0px 14px; line-height:22px; float:left;}
    .ctain_d{ width:520px; height:20px; float:right; border:1px solid #bababa; padding:0px 2px; _height:17px; _padding:3px 2px 0px 2px; margin:0px 36px 0px 6px;}
    .ctain_e{ width:95px; height:20px;border:1px solid #bababa; padding:0px 2px; _height:17px; _padding:3px 2px 0px 2px; margin:0px 36px 0px 6px;}
    </style>
    <script type="text/javascript" src="images/jquery-1.9.1.min.js"></script>
    <script type="text/javascript">
      $(document).ready(function(){
    $(".shanchu").click(function(){
      if ($(".day_list").size() > 1) { 
                  $(this).parent().remove(); 
                    } else {
                     $(".zj_ts").html("一个行程至少有1天"); 
                    } 
    });

    $(".zj_an").click(function(){
     $(".ck").append($(".day_list:first").clone(true));
     $(".zj_ts").html("");
    });
      });
        </script>
    </head>
    <body>
    <div class="top">
      <div class="logo">行程编辑小助手</div>
      <div class="clear"></div>
    </div>
    <div class="box">
      <div class="ck" id="ck">
        <div class="day_list">
          <h2 class="h2_title">第1天 &gt;&gt;<input name="" type="text" class="h2_title_a" id="num-a"/></h2>
          <p class="ctain">行程内容:<input name="" type="text" class="ctain_d" id="num-b"/></p>
          <ul class="ctain">
            <li><strong>用餐</strong> &nbsp;&nbsp;&nbsp;&nbsp;早餐:<input name="" type="text" class="ctain_e" id="num-c"/> 午餐:<input name="" type="text" class="ctain_e" id="num-d"/> 晚餐:<input name="" type="text" class="ctain_e"  id="num-e"/></li>
            <li><strong>住宿</strong> &nbsp;&nbsp;&nbsp;&nbsp;<input name="" type="text" class="h2_title_a" id="num-f"/></li>
          </ul>
          <span class="shanchu"></span>
        </div>
      </div>
      
      <div class="zj">
        <span class="zj_an"></span>
        <span class="zj_ts"></span>
        <span class="zj_bc" onclick="demo()">保存html代码</span>
        <span class="clear"></span>
      </div>
    </div>
    <script type="text/javascript">function demo(){
    var p_text = $(".ck").html();
    document.write(p_text);
    }
    function doCopy(obj){        var codeObj = document.getElementById(obj);        clipboardData.setData('text', codeObj.innerText);        alert('已经复制代码');    }</script>
    </body>
    </html>////demo() doCopy都是做的测试
    兼容性可以先不用考虑clipboardData只支持ie
      

  6.   

    <span class="zj_bc" onclick="demo()">保存html代码</span>换成<span class="zj_bc" onclick="doCopy('ck')">保存html代码</span> ie下测试
    怎么样才能只读出input的值而不是连带imput框一起输出,类似存进数据库里面的html代码
      

  7.   

    可以增加减少JQuery $("").val()无法实现,Dom如何获取输出能给一下示例么?
      

  8.   

    只能說樓主的 jQuery 用法不對
    Write less, do more.
    寫那麼多就不是jquery了jQuery 有 Clone 的方法http://api.jquery.com/clone/
      

  9.   

    DEMO:
    http://jsfiddle.net/oc8d1wyp/
      

  10.   

    思路就是页面上现有的 你不用拿  本来就是固定的 你拿了干嘛?你只要拿  input的 value就可以了
      

  11.   

    有必要存html么?不行就直接把数值存入变量,输出之后再赋值就是了
    var tx = $("#tx").val();
    document.write($("#dd").html());
    $("#tx").val(tx);
    如果你不要input框,那复制干嘛?