Created
August 22, 2019 17:40
-
-
Save parzibyte/3933c1b89e1141390a18f85c2193db0c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Esta función será llamada cada que se haga clic en el botón | |
const accionProducto = function() { | |
// Recuerda: "this" se refiere al elemento | |
const productoComoJson = this.dataset.producto; | |
// Debemos decodificarlo | |
const producto = JSON.parse(productoComoJson); | |
// Y ahora ya podemos acceder a las propiedades del producto | |
console.log("El nombre: ", producto.nombre); | |
console.log("El id: ", producto.id); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment