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;">×</a></div></div>
\<div class="col-sm-2">
\<strong>
\
<a href="javascript:void(0);" class="remCF"><i class="fa fa-times"></i> 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> 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;">×</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> 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>