Skip to content

Instantly share code, notes, and snippets.

@MirzaChilman
Created October 16, 2018 13:36
Show Gist options
  • Save MirzaChilman/d62e740d3e9f2df2a8f6e7b120258cdd to your computer and use it in GitHub Desktop.
Save MirzaChilman/d62e740d3e9f2df2a8f6e7b120258cdd to your computer and use it in GitHub Desktop.
// source https://jsbin.com
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
.box {
background-color: yellowgreen;
width: 35px;
height: 35px;
}
.hitam {
background-color: black;
}
</style>
</head>
<body>
<div class="container">
<p>Box jika di klik berubah warna hitam, dan jika di klik lagi box berubah kembali warna hijau</p>
<div class="box"></div>
</div>
<script>
/* lengkapi variabel const di bawah */
/* =================== */
//const box = document;
/* =================== */
/* https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementsByClassName */
/* lengkapi fungsi di bawah */
/* =================== */
//box.addEventListener('', berubah)
/* =================== */
/* https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener */
function berubah() {
/* lengkapi element di bawah */
/* =================== */
//box.classList
/* =================== */
/* https://developer.mozilla.org/en-US/docs/Web/API/Element/classList */
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment