create div that father of 2 of the 4 brothers

0

I have little with jquery and I am stuck in the problem I mention in the title

I want to create a div with a class that is the parent of form and the last div that appears in the img.

I stayed here:

$(document).ready(function(){

    $(".woocommerce").append('<div class="conjunto">');   

});

I would appreciate the help

    
asked by Carlos 16.10.2018 в 15:56
source

2 answers

0

After searching through several other forums, I found something very similar to your problem here.

link

From what I've seen, there are several ways to put create what you want. I hope that helps you. If you need more help, do not hesitate to comment.

    
answered by 16.10.2018 в 17:37
0

To do this you can use .wrap () , which creates an element that wraps around your indic, I gave you an example by making a parent to form and to < strong> .woocommerce :

$("#crearPadre").on("click", function(e){
  e.preventDefault();
  $(".woocommerce").wrap( "<div class='wrapper'></div>");
});

$("#crearPadre2").on("click", function(e){
  e.preventDefault();
  $("form").wrap( "<div class='wrapper'></div>");
});
.woocommerce{
 border:1px solid red;
 padding:5px;
}

form{
  border:1px solid blue;
}

.wrapper{
 border:1px solid black;
 padding:5px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<div class="woocommerce">
  <form>
    <button id="crearPadre">Crear padre al woocommerce</button>
    <button id="crearPadre2">Crear padre al form</button>
  </form>
</div>
    
answered by 16.10.2018 в 19:18