Advertisement
fcamuso

Corso recupero Javascript - video 11

Nov 24th, 2022
508
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html lang="it">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7.     <style>p{font-size: 18px;}</style>
  8.     <title>Document</title>
  9. </head>
  10. <body>
  11.     <p>
  12.         Lorem ipsum dolor sit amet consectetur adipisicing elit. Voluptate eum blanditiis labore obcaecati nostrum, et minima quisquam ipsa sunt pariatur maiores nulla. Facere quos non, sequi mollitia voluptatem consectetur doloremque.
  13.         Earum, aliquid? Necessitatibus odio nemo perferendis accusantium porro? Rerum debitis dignissimos tempora enim sint soluta. Aliquid obcaecati, quos sunt pariatur iure adipisci aut nobis? Voluptatem beatae optio dolore nemo minus.
  14.         Vel repudiandae, nobis saepe corporis officia nemo impedit eligendi natus inventore ullam dolor dicta voluptate alias veritatis corrupti earum, dignissimos odio molestiae ad, quos similique quas tempore molestias? Illo, unde!
  15.         Repellat animi voluptates voluptatem omnis dolore eligendi tenetur tempore? Facilis suscipit nulla pariatur in! Dolor, sed blanditiis. Assumenda optio consequatur debitis esse quaerat, eius ipsa accusantium nam cupiditate repudiandae aperiam.
  16.         Odio incidunt corporis, culpa sapiente, magni rem velit quos corrupti laudantium repudiandae cumque dignissimos ducimus eum repellendus? Rerum ipsam officiis facere nulla magnam quidem? Mollitia quidem maxime excepturi rerum nulla.
  17.     </p>
  18.  
  19.     <script>
  20.         const colori = ["red", "yellow", "blue", "green", "purple"];
  21.         const colorePartenza="black";
  22.  
  23.         let indiceColore = 0;
  24.         document.querySelector("p").addEventListener("click", function () {
  25.            this.style.color = colori[indiceColore];
  26.            indiceColore++;
  27.            if (indiceColore===colori.length) indiceColore=0;
  28.         })
  29.     </script>
  30.    
  31.  
  32. </body>
  33. </html>
  34. *********************************************************
  35. *********************************************************
  36.  
  37. <!DOCTYPE html>
  38. <html lang="it">
  39. <head>
  40.     <meta charset="UTF-8">
  41.     <meta http-equiv="X-UA-Compatible" content="IE=edge">
  42.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  43.     <style>p{font-size: 18px;}</style>
  44.     <title>Document</title>
  45. </head>
  46. <body>
  47.     <img src="#" alt="immagine non specificata" ><br>
  48.     <button id="1">1</button><button id="2">2</button><button id="3">3</button><button id="4">4</button>
  49.  
  50.     <script>
  51.       const bottoni = document.querySelectorAll("button");
  52.       for (let i=0; i<bottoni.length; i++)
  53.         bottoni[i].addEventListener("click", function () {
  54.           const id = this.textContent;
  55.           document.querySelector("img").src="londra/londra"+id+".jpg";
  56.         })
  57.     </script>
  58.    
  59.  
  60. </body>
  61. </html>
  62. *********************************************************
  63. *********************************************************
  64. <!DOCTYPE html>
  65. <html lang="it">
  66. <head>
  67.     <meta charset="UTF-8">
  68.     <meta http-equiv="X-UA-Compatible" content="IE=edge">
  69.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  70.     <title>Lampada</title>
  71.     <style>
  72.         .stelo,.base{
  73.             background-color: #000;
  74.         }
  75.         .base{
  76.             width: 160px;
  77.             height: 20px;
  78.             margin: 0 20px;
  79.         }
  80.         .stelo{
  81.             width: 20px;
  82.             height: 100px;
  83.             margin-left: 90px ;
  84.         }
  85.         .lampada{
  86.             width:100px;
  87.             height:0;
  88.             border-bottom: 200px solid black;
  89.             border-left: 50px solid transparent;
  90.             border-right: 50px solid transparent;
  91.         }
  92.         .interruttore{
  93.             height: 100px;
  94.             width: 50px;
  95.             font-size: 50px;
  96.             color: #FFF;
  97.             background-color: #000;
  98.             text-align: center;
  99.             padding: 20px 0;
  100.             box-sizing: border-box;
  101.             margin-top: 50px;
  102.         }
  103.         .interruttore:hover{
  104.             cursor: pointer;
  105.         }
  106.     </style>
  107. </head>
  108. <body>
  109.     <div class="lampada">&nbsp;</div>
  110.     <div class="stelo">&nbsp;</div>
  111.     <div class="base">&nbsp;</div>
  112.     <div class="interruttore">0</div>
  113.  
  114.     <script>
  115.         document.querySelector(".interruttore")
  116.           .addEventListener("click", function () {
  117.            
  118.             const lampada = document.querySelector(".lampada");
  119.             if (this.textContent==="0")
  120.             {
  121.                 this.textContent="1";
  122.                 lampada.style.borderBottomColor = "yellow";
  123.             }
  124.             else
  125.             {
  126.                 this.textContent="0";
  127.                 lampada.style.borderBottomColor = "black";
  128.  
  129.             }
  130.           })
  131.     </script>
  132. </body>
  133. </html>
  134.  
  135.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement