Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>
- Element Tebal dan Tidak
- </title>
- </head>
- <body>
- <ul>
- <li>Jeruk</li>
- <li>Mangga</li>
- <li>Pisang</li>
- <li>Jambu</li>
- <li>Pepaya</li>
- <li>Alpukat</li>
- <li>Pir</li>
- <li>Anggur</li>
- </ul>
- <button onclick="changeElement()">Ubah Warna Element Genap</button>
- <script>
- function changeElement(){
- var list = document.getElementsByTagName('li');
- // list[1].style.color = "blue";
- // list[1].style.fontWeight = "bold";
- // list[3].style.color = "blue";
- // list[3].style.fontWeight = "bold";
- // list[5].style.color = "blue";
- // list[5].style.fontWeight = "bold";
- // list[7].style.color = "blue";
- // list[7].style.fontWeight = "bold";
- for(var i = 0; i < list.length; i++){
- if(i % 2 == 0){
- continue;
- } else {
- list[i].style.color = "blue";
- list[i].style.fontWeight = "bold";
- }
- }
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement