Incorporar Javascript
1.- En linea
<!DOCTYPE html> <html lang=”es”> <head> <title>Este texto es el título del documento</title> </head> <body> <div id=”principal”> Hacer Clic No puede hacer clic </div> </body> </html>
2.- Embebido
<!DOCTYPE html> <html> <body> <p>Muestra de evento "onclick" </p> <p id="demo" onclick="myFunction()">Click me.</p> <script> function myFunction() { document.getElementById("demo").innerHTML = "YOU CLICKED ME!"; } </script> </body> </html>
3.- Archivo externo
<!DOCTYPE html> <html lang="es"> <head> <title>Nuevos Estilos CSS3</title> <link rel="stylesheet" href="nuevocss3.css"> </head> <body> <header id="principal"> <span id="titulo">Estilos CSS Web 2.0</span> </header> </body> </html>
Variables
// var, let, const, scope var myValue = 'Hello World'; var myNum = 10; let a = 100; let b = 200; const c = 300; if(a){ console.log(a); let d = "Anything"; console.log(d); } console.log(d); console.log(a,b,c); let result = prompt("what is your name?","None"); console.log(result ); console.log(document); console.dir(document);
Tipos de datos
- Boolean
- Null
- Undefined
- Number
- String
- Symbol
- Objeto ( en JS todo son objetos sino se indica otro tipo)
Podemos usar typeof para saber que tipo de datos usa una variable.
Comentarios recientes