Good afternoon fellows, I am new to using Spring Boot and I need your support please.
From my controller class(@Conroller) it sent data to my Jsp and the data is displayed correctly, but when I click on the anchor- tag it does not show me the value of the tag with class nameproduc when using Jquery, and it shows me the value of the div I am looking to replace; thanks first of all.
<div class="row">
<div class="col-md-12 my-4 mt-md-3 mb-md-5">
<div class="h4">Más Productos similares:</div>
</div>
<div class="col-12 col-md-12 bg-shad pt-4 pb-1">
<div class="owl-carousel owl-theme text-center" id="gallery_01">
<!-- me muestra 12 grupos similares: -->
<c:forEach items="${producto}" var="producto">
<a href="#" class="selecproduct item thumb-wrapper text-decoration-none" data-image="${urlPublic}/imagenes/frutas/${producto.proimagen}" data-zoom-image="${urlPublic}/imagenes/frutas/${producto.proimagen}">
<div class="border rounded" >
<img src="${urlPublic}/imagenes/frutas/${producto.proimagen}" alt="" class="">
<div class="nameproduc">${producto.nomProducto}</div>
<span class="precioproduct">${producto.precio}</span>
<div class="d-none">${producto.dataFilPro}</div>
</div>
</a>
</c:forEach>
</div>
</div>
</div>
<script>
$(".selecproduct").click(function(){
var nombPro = $(".nameproduc").html();
alert(nombPro);
});
I hadn't realized that the div is inside the link.
$(this)
it references the link that was clicked$(this).find('.clase')