Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*$(document).ready(function(){
- alert("HOLA");
- }
- ) ES LO MISMO QUE : $(*/
- // let define y/o redefine variables dentro de un bloque (ej.if, for, switch pero no case..)
- let variable="hola";
- if (true){
- let variable="adios";
- console.log(variable);
- }
- console.log (variable);
- var opcion=2;
- switch(opcion){
- case 1:
- console.log("jajajaj");
- let variable="adios";
- break;
- case 2:
- console.log("jejejjeje");
- break;
- case 3:
- console.log ("jijiji")
- break;
- }
- // En este ejemplo podemos realizar cada bucle (10x10 repeticiones),
- //al contrario de si empleasemos var i (x10 iteraciones)
- /*for (let i=0; i<10; i++){
- for (let i=0; i<10; i++
- }*/
- $(function(){
- $("#mario") // equivale a getElementById("mario");
- });
- $(function(){
- alert($("#mario").html());
- });
- $(function(){
- //$("h3").html("algo"); //todos los h3 tendrán ahora contenido "algo"
- $("h3").eq(2).html("algo"); //eq()cambia el contenido de los h3 indicados en ("") por "algo".Ojo! no los guarda
- $("h3").css("fontSize","50px"); //cambiamos la propiedad css de un elemento
- $("h3").css({ //cambiamos varias propieades css de un elemento
- "fontSize":"50px",
- "color":"red",
- });
- $("h3").on("click",function(){ //al hacer click cambia a verde los h3
- $("h3").css("color","green");
- });
- });
- $(function(){
- $("h3").eq(2).html("algo");
- $("h3").on("click",function(){
- $("h3").css("color","green");
- });
- });
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title> Probando con jQuery </title>
- <meta name="author" content="María José">
- <meta name="description" content="Curso desarrollo de aplicaciones con
- tecnologías web">
- <!--<link rel="stylesheet" href="estilos_css.css" media="all"-->
- <script src="../js/jquery-3.2.0.min.js"></script>
- <!--script src="https://code.jquery-3.2.0.min.js"></script-->
- <script src="../js/miprimerjquery.js"></script>
- </head>
- <body>
- <div>
- <p id="mario">hola mario</p>
- <h3></h3>
- <h3></h3>
- <h3></h3>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement