simplifying the code a bit because it is very extensive I have this html
<div class="quantity buttons_added">
<input type="number" size="4" class="input-text qty text" title="Qty"
value="1" min="0" step="1" name="cantidad_{{$contador}}">
<a href="" class="btn btn-warning actualizaCantidad_{{$contador}}"
data-linkcarrito="{{url('/carrito/'.$elementocarrito->slug)}}"
data-cantidadidentificador="{{$contador+1}}"><i class="fa
fa-refresh"></i></a>
</div>
This code is dynamic, so in Jquery I want you to select all the classes that start with "updateQuantity" and once selected to give each individual link get an amount and a link, and redirect me to that same link, the problem is that when I click, it never does preventDefault (), I always end up loading the page. I have tried putting # in the links, with javascript: void () and with this I can avoid the execution of the page, but it does not redirect me to any place. I've tried with e.preventDefault (); with e.stopPropagation (); and with false return and same result. I have tried alert ('JQUERY WORKS'); to see if I load it at the top of the page and load it perfectly, so some error not load well jquery is discarded.
Any ideas?
$('document').ready(function(){
alert('JQUERY FUNCIONA ');
$('a[class^="actualizaCantidad"]').click(function(e)
{
e.preventDefault();
e.stopPropagation()
var cantidad = $(this).data("cantidadidentificador");
var href = $(this).data("linkcarrito");
//$(location).attr("href", href);
window.location.href = href;
//alert(cantidad+' '+ href);
}); });