I'm working on a web application implementing HTML
, JAVASCRIPT
, JQUERY
From JAVASCRIPT
, I am adding code HTML
, to generate buttons, as needed, within for
, but I only add as I am adding it with the following code:
x +="<button type=\"button\" class=\"btn boton-eliminar-tratamiento\" name=\"DIENTE-1-TRATAMIENTO-1"\" >ELIMINAR</button>";
document.getElementById("p-tratamientos").innerHTML = x;
Until then everything works well for me. The buttons do appear in the HTML. My problem is when I now want to see if the user pressed that button. Try it with the following code:
$(".boton-eliminar-tratamiento").click(function(){
alert('Ha hecho click sobre el boton');
return true;
});
In theory you should do it, but I'm pretty sure you have to see the button generate it dynamically from JS
with innerHTML
and that's why it does not enter the click
.