I have divs that are generated dynamically with a button. You can now generate them with the following script:
var contenedor = $(".inputs");
$(".agregar").click(function(e){
add_control(contenedor);
$(".agregar, .nth").hide();
e.preventDefault();
});
function add_control(contenedor){
ctr = ctr + 1;
contenedor.append('<div class="btun"><input type="text" class="ed" value="" id="tb' + ctr + '' +'"/>'+
'<button class="agregar_in">+</button>'+
'<button class="eliminar_in">-</button></div>');
console.log(ctr);
}
So far so good, now this, as you can see, generates two buttons.
My question is, how can I disable the button with the class agregar_in
that I generate if I give two or more times click, that is,
<button class="agregar">+</button>
<div class="inputs"></div>
<div class="btun">
<input type="text" class="e" value id="tb1">
<button class="agregar_in">+</button>
<button class="eliminar_in">-</button>
</div>
<div class="btun">
<input type="text" class="e" value id="tb2">
<button class="agregar_in">+</button>
<button class="eliminar_in">-</button>
</div>
In this case, it would be the one after tb1 (disable)