doule6314 2019-04-27 07:07
浏览 68

在onclick上找到最接近的div并附加div

Here i want to append the div to the parent div using closest function.Here is my code please have a look

    var maxAppends = 0;
    function add_field(id)
     {
      
    var update_new = $('<div class="form-group" style="margin-bottom: 0px">
\
                      <label for="field-1" class="col-sm-4 control-label">Documentsss</label>
\
                      <div class="col-sm-5">
\
                      <div class="fileinput fileinput-new" data-provides="fileinput">
\
                      <span class="btn btn-default btn-file"><span class="fileinput-new" >Select file</span><span class="fileinput-exists" >Change</span><input type="file" name="files[]" ></span> <span class="fileinput-filename"></span><a href="#" class="close fileinput-exists" data-dismiss="fileinput" style="float: none;">&times;</a></div></div>
\<div class="col-sm-2">
\<strong>
\
                      <a href="javascript:void(0);" class="remCF"><i class="fa fa-times"></i>&nbsp;Remove</a></strong></div>');

    $(".update_new_"+id).append(update_new);
    maxAppends++;
         
       
    }
    <div id="update_new_<?php echo $value->id;?>" class="update_new_<?php echo $value->id;?> item-row">
                <div class="form-group mb0" style="margin-bottom: 0px">
                    <label for="field-1"
                           class="col-sm-4 control-label">Other Document</label>
                    <div class="col-sm-5">
                        <div class="fileinput fileinput-new" data-provides="fileinput">
                            <?php
                            if (!empty($value->documents)) {
                                $uploaded_file = json_decode($value->documents);
                            }
                            if (!empty($uploaded_file)):foreach ($uploaded_file as $v_files_image): ?>
                                <div class="">
                                    <input type="hidden" name="fileName[]"
                                           value="<?php echo $v_files_image ?>">
                                  
                                    <span class=" btn btn-default btn-file">
                                    <span class="fileinput-filename"> <?php echo $v_files_image ?></span>
                                    <a href="javascript:void(0);" class="remCFile" style="float: none;">×</a>
                                    </span>
                                    <strong>
                                        <a href="javascript:void(0);" class="RCF"><i
                                                class="fa fa-times"></i>&nbsp;Remove</a></strong>
                                    <p></p>
                                </div>

                            <?php endforeach; ?>
                            <?php else: ?>
                                <span class="btn btn-default btn-file"><span
                                        class="fileinput-new">Select File</span>
                                                            <span class="fileinput-exists"><?= lang('change') ?></span>
                                                            <input type="file" name="files[]">
                                                        </span>
                                <span class="fileinput-filename"></span>
                                <a href="#" class="close fileinput-exists" data-dismiss="fileinput"
                                   style="float: none;">&times;</a>
                            <?php endif; ?>
                        </div>
                        <div id="msg_pdf" style="color: #e11221"></div>
                    </div>
                    <div class="col-sm-3">
                        <strong><a href="javascript:void(0);" id="update_more" onclick="add_field('<?php echo $value->id;?>');" u_id="<?php echo $value->id;?>" class="addCF item-row-click update_more_<?php echo $value->id;?>"><i
                                    class="fa fa-plus"></i>&nbsp;Add More
                            </a></strong>
                    </div>
                </div>

                

            </div>

when i click add_field i want a div to append to the parent div with class update_new_<?php echo $value->id;?>,so in order to that i had done a script.please have a look

without using closest function the div is appending but the values of div is not passing the value through post,so i want to do the append function with closest function,please help me to solve

</div>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
    • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 保护模式-系统加载-段寄存器
    • ¥15 电脑桌面设定一个区域禁止鼠标操作
    • ¥15 求NPF226060磁芯的详细资料