简体   繁体   中英

Jquery append with find doesn't work together

Hello I am trying to insert one dom element to another but somehow it doesn't work. I have done this alot before but this time I couldn't understand why.

This is my modal box. I am getting this with ajax request and I am using $.when and get two pages together. Which you will find second html below.

First :

 <div class="edit-modal">
<div class="edit-modal-title">
  <h1>Settings</h1>
</div> <!-- edit-modal-title -->
<div class="edit-modal-menu">
  <ul class="list-inline">
    <li><a href="#">Edit Form</a></li>
    <li class="edit-active"><a href="#">Add People</a></li>
    <li><a href="#">Form Info</a></li>
  </ul>
</div> <!-- edit-modal-menu -->
<div class="edit-modal-content">
  <!--  people -->
</div>

Second :

<div class="form-group">
  <label for="name">Form Name</label>
  <input type="text" class="input-style form-control" id="name" placeholder="E-mail">
</div>
<div class="form-group">
  <label for="ty">Thank You Page</label>
  <input type="text" class="input-style form-control" id="ty" placeholder="Password">
</div>
<div class="checkbox">
  <label>
    <input type="checkbox"> E-mail Notification
  </label>
</div>
<button type="submit" class="save-button step-button">Save</button>
<a href="#" class="pull-right" style="text-decoration:underline; font-style:oblique;">delete form</a>

I just want to put second part in .edit-modal-content div.

I am doing like this;

  $(first[0]).find('.edit-modal-content').append(second[0]);

But when console.log($(first[0])) there is no second part in .edit-modal-content how can I fix it ?

Thanks

First, if it is not a typo, your "First" is missing a closing div at the very bottom. After you fix that, if it is a typo, you should be able to do:

var $something = $(first).find('.edit-modal-content').append($(second));

Then when you are ready you can append that to the body.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM