Skip to content

Instantly share code, notes, and snippets.

@agustinpfs
Last active June 12, 2020 13:28
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 agustinpfs/98ac20b09dd58fe2d3a29737e0f99c30 to your computer and use it in GitHub Desktop.
Save agustinpfs/98ac20b09dd58fe2d3a29737e0f99c30 to your computer and use it in GitHub Desktop.
Javascript básico. DOM.
<!-- Document.getElementById(”valor del atributo id”) devuelve el
elemento que tiene el atributo ID con el valor especificado. -->
<!-- <html>
<body>
<p id="nombreId">GetElementById</p>
<script>
let elemento = document.getElementById("nombreId")
</script>
</body> -->
<!-- ver let elemento en devtools -->
<!-- Document.write() escribe un texto en el documento HTML -->
<!-- <script>
document.write("Hola Mundo!"); // Hola Mundo! (en el navegador)
</script> -->
<!-- Element.innerHTML inserta contenido en el elemento indicado -->
<!-- <html>
<body>
<p id="nombreId"></p>
<script>
let saludo = "Hola Mundo";
let elemento = document.getElementById("nombreId").innerHTML = saludo;
</script>
</body>
</html> -->
<html>
<body>
<h1 id="saludo">Hola mundo</h1>
<script>
document.getElementById("saludo").style.color = "blue";
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment