谷大羽 2017-07-24 10:49 采纳率: 0%
浏览 3895

jquery的append动态添加元素后为什么会全局刷新页面

 需求是自定义的属性需要显示在页面上,
//自定义属性
    $("#addAttr").click(function(){
        //获取自定属性的属性名称类型和要素类别
        var attrPage= $("#attrPage").val();
        var attrName= $("#attrName").val();
        var attrCate= $("#attrCate").val();
        //保存在数据库中

        //在前台展示       
        alert("attrPage:"+attrPage+" attrName:"+attrName+" attrCate:"+attrCate);
        var html="<input name='"+attrName+"' type='checkbox'>"+attrName+"</input>";

        if(attrPage == 1){
            $("#baseInfo").append(html);
        }else if(attrPage == 2){
            $("#marketInfo").append(html);
        }else if(attrPage == 3){
            $("#accessoryInfo").append(html);
        }else if(attrPage == 4){
            $("#brokerage").append(html);
        }

    });

    <div id="instranceInfoTemplate" class="span12" style="display:none;">
                <form id="instranceInfoAttr" role="form">
                  <div id="baseInfo" class="form-group">
                    <label for="name">产品基本信息</label>
                        <input id="productFeature" name="productFeature" type="checkbox" /> 产品特点 &nbsp;&nbsp; 
                        <input id="premium" name="premium" type="checkbox" /> 参考保费&nbsp;&nbsp; 
                        <input id="productIntroduce" name="productIntroduce" type="checkbox" /> 产品介绍 &nbsp;&nbsp; 
                        <input id="sort" name="sort" type="checkbox" /> 产品排序 &nbsp;&nbsp; 
                  </div>
                  <div id="marketInfo" class="form-group">
                    <label for="name">产品营销信息</label>
                        <input id="productFeature" name="productFeature" type="checkbox" /> 产品小图 &nbsp;&nbsp; 
                        <input id="premium" name="premium" type="checkbox" /> 产品大图&nbsp;&nbsp; 
                        <input id="productIntroduce" name="productIntroduce" type="checkbox" /> 产品营销文案 &nbsp;&nbsp; 
                        <input id="sort" name="sort" type="checkbox" /> 风险提示信息 &nbsp;&nbsp; 
                  </div>
                  <div id="accessoryInfo" class="form-group">
                    <label for="name">产品附件信息</label>
                        <input id="productFeature" name="productFeature" type="checkbox" /> 添加产品附件 &nbsp;&nbsp; 
                  </div>
                  <div id="brokerage" class="form-group">
                    <label for="name">产品佣金信息</label>
                        <input id="productFeature" name="productFeature" type="checkbox" /> 产品折标率 &nbsp;&nbsp; 
                        <input id="premium" name="premium" type="checkbox" /> 内部咨询师顾问佣金分成比例 &nbsp;&nbsp; 
                        <input id="productIntroduce" name="productIntroduce" type="checkbox" /> 外部咨询师佣金分成比例 &nbsp;&nbsp; 
                  </div>
                  <input type='button' class='btn btn-large btn-primary' data-toggle='modal' data-target='#myModal'>自定义添加属性</button>
                  <button type="submit" class="btn btn-default">提交</button>
                </form>
            </div>
  • 写回答

2条回答 默认 最新

  • devmiao 2017-07-24 13:18
    关注
    评论

报告相同问题?

悬赏问题

  • ¥15 r语言蛋白组学相关问题
  • ¥15 Python时间序列如何拟合疏系数模型
  • ¥15 求学软件的前人们指明方向🥺
  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 STM32驱动继电器