-
-
Save parzibyte/c05701f92ab0e8f7467420c329385be8 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
$(document).ready(function () { | |
const $select = $("#miSelect"); | |
const opcionCambiada = () => { | |
console.log("Cambio"); | |
}; | |
$select.change(opcionCambiada); | |
const agregar = () => { | |
const valor = new Date().getTime(); | |
$select.append($("<option>", { | |
value: valor, | |
text: valor | |
})); | |
}; | |
const limpiar = () => { | |
$select.empty(); | |
}; | |
const mostrar = () => { | |
const valor = $("#miSelect :selected").val(), | |
texto = $("#miSelect :selected").text(); | |
alert(`Texto: ${texto}. Valor: ${valor}`); | |
}; | |
$("#btnAgregar").click(agregar); | |
$("#btnLimpiar").click(limpiar); | |
$("#btnMostrar").click(mostrar); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment