【发布时间】:2019-01-19 14:51:54
【问题描述】:
所以我有这个
{% for producto in reparto_martes %}
<div class="col-md-3">
<div class="card mb-4 box-shadow product-box">
<img class="card-img-top product-photo" data-src="holder.js/100px225?theme=thumb&bg=55595c&fg=eceeef&text=Thumbnail" alt="Thumbnail [100%x225]" style="height: 225px; width: 100%; display: block;" src={{ producto.foto }} data-holder-rendered="true">
<div class="card-body">
<h4 class="card-text producto_precio">${{ producto.precio }}</h4>
<h5 class="card-text producto_nombre">{{ producto.nombre }}</h5>
<div class="d-flex justify-content-between align-items-center">
<button type="button" class="btn btn-success anadir_button">Añadir</button>
<small class="text-muted"></small>
</div>
</div>
</div>
</div>
{% endfor %}
看起来像这样:https://gyazo.com/0b329d87af9372250a53ae25347b59b0
当用户点击 anadir_button 时,我需要选择项目名称。
$(document).ready(function(){
$(".anadir_button").click(function(){
$('.producto_precio').clone().appendTo('#list_pedidos');
});
});
^这一项只选择了所有三个项目(香蕉、bolson frutal、almendras)
$('.producto_precio').last()clone().appendTo('#list_pedidos');
^而这只是选择'almendras'。
【问题讨论】:
标签: jquery django bootstrap-4 selector