SHARE
TWEET

Untitled

wildanfuady Nov 8th, 2019 88 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <html>
  2.     <head>
  3.         <title>
  4.             Javascript Pertama
  5.         </title>
  6.     </head>
  7.     <body>
  8.         <div id="kalimat">Saya sedang belajar Javascript</div>
  9.         <p class="tengah">Lorem ipsum, dolor sit amet consectetur adipisicing elit. Minima natus laudantium, assumenda libero atque consequuntur molestias voluptatibus optio voluptates inventore eaque illo, cumque sapiente! Voluptatibus debitis similique id praesentium? Odit.</p>
  10.         <p class="tengah">Lorem ipsum, dolor sit amet consectetur adipisicing elit. Minima natus laudantium, assumenda libero atque consequuntur molestias voluptatibus optio voluptates inventore eaque illo, cumque sapiente! Voluptatibus debitis similique id praesentium? Odit.</p>
  11.         <button onclick="editData()">Ubah Kalimat</button>
  12.         <script>
  13.             function editData(){
  14.                 // sintax untuk mengambil data berdasarkan id
  15.                 var kalimat = document.getElementById('kalimat');
  16.                 kalimat.innerHTML = "Saya sedang belajar Web Design";
  17.                 kalimat.style.color = "blue";
  18.                 kalimat.style.fontSize = "40px";
  19.                 kalimat.style.textAlign = "center";
  20.  
  21.                 var paragraf = document.getElementsByClassName('tengah');
  22.                 // paragraf[0].style.textAlign = "center";    
  23.                 // paragraf[0].style.color = "red";    
  24.                 // paragraf[1].style.textAlign = "right";    
  25.                 // paragraf[1].style.color = "blue";
  26.  
  27.                 for(var i = 0; i < paragraf.length; i++){
  28.                     paragraf[i].style.textAlign = "center";    
  29.                     paragraf[i].style.color = "red";    
  30.                 }
  31.             }
  32.         </script>
  33.     </body>
  34. </html>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top