function karzina (){ $('.zakaz').click(function(){ var chto_id = $(this).parent().attr('id'); var chto = $(this).parent(); var sprav = $('.tovar').attr('id'); var pText = $(chto).find("#rectangle p").text(); var colText = $(chto).find("#colznach").text(); var cenText = $(chto).find("span#cenznach").text(); var idExists = false; $('.tovar').each(function(){ if(this.id == chto_id){ idExists = true; } }); if (idExists){ console.log("true"); } else { $('.doska').append('<div class="tovar" id='+chto_id+'> <div id="dosname"> </div> <div id="doscol"> </div> <div id="doscen"></div></div>'); }; }); }; 

When clicking, divas are created within which there are three divas, in these three divas the text taken from the item card should be displayed, the problem is that all the text is recorded inside the first diva created and not by its identifier. How to do this? html This is a basket

And this is a product site on a modic

 <div class="col-md-4 col-xs-12 col-sm-6 pos79" id="79"> <div class="kartochka"> <img height="187" src="/assets/uploads/sushi-i-rollyi/spays-sushi/spays-abi.jpg" alt=""> <div id="rectangle"><p>Спайс эби</p></div> </div> <div class="opisanie"> <p>Рис, икра лосося, нори</p> </div> <div id="colichestvo">количество: <span id="colznach"></span></div> <div id="cena">цена <span id="cenznach">350тг</span></div> <div class="zakaz"> заказать </div> 
  • html add to the question, or an example that will show how your DOM tree is built - Vasily Barbashev
  • one
    We need exactly generated html. And where is .doska - Vasily Barbashev
  • one
    I do not see that something is recorded by the identifier) ​​There is no such code. And in addition, the future id can not begin with a number, if you need to create such meta-data, write them to data-id="id" , and you can get them $(this).data('id') - Vasily Barbashev

0