A Pen by Mochamad Adi MR on CodePen.
Created
February 5, 2024 07:25
-
-
Save adimuhamad/3121051b2b2ea2568031aedc78d65383 to your computer and use it in GitHub Desktop.
WNmyrBe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Do you love me?</title> | |
</head> | |
<body class="mt-3"> | |
<div class="container-fluid"> | |
<img id="gambar-gif" src="https://i.pinimg.com/originals/75/9d/52/759d52d9562a4ccdfd45d2319a285284.gif" alt="Gambar GIF" style="width: 150px; height: auto;"> | |
<h2 id="question-text">Kamu sayang sama aku ga?</h2> | |
<button type="button" class="btn btn-success mb-2" id="iya" onclick="responTombolIya();">SAYANG DONG!</button> | |
<button type="button" class="btn btn-danger" id="tidak" onmouseover="pindahTempat();">NGGA LAH!</button> | |
</div> | |
</body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function pindahTempat() { | |
var buttonTidak = document.getElementById('tidak'); | |
var maxWidth = window.innerWidth - buttonTidak.clientWidth; | |
var maxHeight = window.innerHeight - buttonTidak.clientHeight; | |
var newX = Math.random() * maxWidth; | |
var newY = Math.random() * maxHeight; | |
buttonTidak.style.position = 'absolute'; | |
buttonTidak.style.left = newX + 'px'; | |
buttonTidak.style.top = newY + 'px'; | |
} | |
function responTombolIya() { | |
var gambar = document.getElementById('gambar-gif'); | |
var elemenTeks = document.getElementById('question-text'); | |
var elemenTombolIya = document.getElementById('iya'); | |
var elemenTombolTidak = document.getElementById('tidak'); | |
gambar.src = 'https://media.tenor.com/gUiu1zyxfzYAAAAj/bear-kiss-bear-kisses.gif'; | |
elemenTeks.innerText = "Yeayyy... I Love You!"; | |
elemenTombolIya.style.display = 'none'; | |
elemenTombolTidak.style.display = 'none'; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.container-fluid { | |
display: flex; | |
flex-direction: column; | |
align-items: center; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.0.2/css/bootstrap.min.css" rel="stylesheet" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment