-1
Good evening! I have the following problem: when the user clicks on "Add Cart" the item should appear in payments (as shown in picture 1). How would I send all this div by javascript? Or what is the best solution in this case, since each product in the cart will have a title, a price, an image?
HTML of the complete div:
I would like to "instantiate" this code every time the user adds a new product.
<!-- GRID de cada produto -->
<div class="container-fluid" id="modeloProdutos">
<div class="row">
<!-- descrição produtos + imagem -->
<div class="col-sm-12 col-md-4 col-lg-6">
<img src="img/arroz.jpg">
<p id="descricaoProduto">...<p>
</div>
<div class="col-sm-12 col-md-4 col-lg-2">
<!-- informar quantidade de produtos -->
<div class="container-fluid divAddProdutosPagamentos">
<div class="row">
<!-- Botão de subtrair -->
<!-- nao consigo redimensionar o botao -->
<div class="input-group-prepend col-lg-3" id="buttonMinus">
<button class="btn btn-primary" type="button"><i class="fas fa-minus"></i></button>
</div>
<!-- Campo p/ informar a qtd-->
<!-- aqui vai setado a quantidade de itens informado no index -->
<input type="text" class="form-control input-group-prepend col-lg-3 inputQtd"
value="1">
<!-- Botão de adicionar -->
<div class="input-group-prepend col-lg-3 buttonAdd">
<button class="btn btn-primary" type="button"><i class="fas fa-plus"></i></button>
</div>
</div>
</div> <!-- FIM DA DIV ADD PRODUTO -->
Template: (. modelProducts is my class that contains all the css style, #bodyPrincipal is my body ID with css style)
$(document).ready(function(){
$('#botao').click (function(){
var _template = $('.modeloProdutos').html();
$("#bodyPrincipal").append(_template);
});
});
Hello Taffarel, thank you very much for your solution. I am trying to understand for parts the code that instructed me. When I run the above code, a new div is successfully generated, but without the css formatting. I tried to replace the "id" with "class" but it didn’t work either. Can you tell me if it’s solvable? I entered the code in the theme .
– Weslley Fillipe
Right. Send the code you’re implementing so we can take a look.
– Taffarel Xavier