I have the following element in my project:
Individual code for each box
<div class="col-md-3 col-sm-6 col-xs-12">
<div class="info-box bg-aqua">
<span class="info-box-icon"><i class="fa fa-bookmark-o"></i></span>
<div class="info-box-content">
<span class="info-box-text">Caja</span>
<span class="info-box-number">41,410</span>
<div class="progress">
<div class="progress-bar" style="width: 70%"></div>
</div>
<span class="progress-description">
70% Increase in 30 Days
</span>
</div>
<!-- /.info-box-content -->
</div>
<!-- /.info-box -->
</div>
The issue is that the sample depending on the box number, can be 1 or 1000, the question is that I want to return the element clickable as a <a href="">
but that does not direct me to any page but that I do an action like is DEPENDING which box clickee:
$(".caja1").click(function() {
console.log("Clickeo la caja # X");
});
How can I re-click the element and at the same time in javascript know which element to click?
Thank you very much for the help.
EDITED
Updated code to the answers but does not throw anything (Affect that is showing dynamically in the operation of .click()...
?)
$("#buscarLote").click(function() {
var valor = document.getElementById("loteBuscar").value;
var totalCajas;
var iter = [];
$.ajax({
url: "views/ajax/OIT.php",
method: "GET",
data: { funcion: "funcion6", box: valor },
async: false,
dataType: "json",
success: function(respuesta) {
totalCajas = respuesta.cantidadCajas;
//console.log(respuesta.cantidadCajas);
for (var i = totalCajas; i > 0; i--) {
$(".contenedorCajas").append('<div class="col-md-3 col-sm-6 col-xs-12 cajas" id="' + (i - 1) + '"><div class="info-box bg-aqua"><span class="info-box-icon"><i class="fa fa-cube"></i></span><div class="info-box-content"><span class="info-box-text">Caja ' + (i - 1) + '</span><span class="info-box-number">41,410</span><div class="progress"><div class="progress-bar" style="width: 70%"></div></div><span class="progress-description">70% Increase in 30 Days</span></div><!-- /.info-box-content --></div><!-- /.info-box --></div>');
}
}
});
});
$(".cajas").click(function() {
console.log($(this.id));
});