Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created August 22, 2019 17:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/363b12eea85495c84cf49ce9355f0b60 to your computer and use it in GitHub Desktop.
Save parzibyte/363b12eea85495c84cf49ce9355f0b60 to your computer and use it in GitHub Desktop.
// El td del botón
let $tdBoton = document.createElement("td");
let $boton = document.createElement("button");
// dataset solo permite guardar cadenas, por eso codificamos como JSON
$boton.dataset.producto = JSON.stringify(producto);
$boton.textContent = "Acción";
// En el click llamamos a la función definida anteriormente
$boton.addEventListener("click", accionProducto);
$tdBoton.appendChild($boton);
$tr.appendChild($tdBoton);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment