Last active
March 13, 2026 20:41
-
-
Save FernandoVCG33/d0fc44a15d804a4eb3648258981ea697 to your computer and use it in GitHub Desktop.
Crear o cambiar una id o class
This file contains hidden or 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
| let elemento1=document.getElementById("elemento1"); | |
| let elemento2=document.getElementById("elemento2"); | |
| //Metodo1 | |
| elemento2.setAttribute("class", "verde"); | |
| //crear nuevo | |
| elemento2.setAttribute("id", "hola"); | |
| //Metodo2 | |
| elemento1.className="amarillo"; | |
| elemento1.id="otroId"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment