You see, I was starting a new project. But I encountered a problem. I want the user to choose an option and delete all other options but somehow it just doesn't work. Btw I am using Chrome latest version. Just ignore the chinese words.
Here's the HTML5:
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Rock Paper Scissors</title>
<link rel="stylesheet" href="style.css">
<body>
<script src="script.js"></script>
<p>
</p><div class="Title-en" align="center" draggable="false">Rock Paper Scissors<br></div>
<div class="Title-ch" align="center" draggable="false">石头剪刀布</div>
</p>
<div class="command-en" draggable="false">
<p>Please select one</p>
</div>
<div class="command-ch" draggable="false">
<p>请选择一个</p>
</div>
<div class="vertical-line"></div>
<div draggable="false">
<p id="img-rock">✊</p>
</div>
<div draggable="false">
<p id="img-paper">✋</p>
</div>
<div draggable="false">
<p id="img-scissors">✌</p>
</div>
</body>
</html>
Here's the Javascript:
let rock = document.getElementById("img-rock");
let scissors = document.getElementById("img-scissors")
let paper = document.getElementById("img-paper")
}
if (rock){
rock.addEventListener("click", rock_del);
}
if(scissors){
scissors.addEventListener("click", scissors_del);
}
if(paper){
paper.addEventListener("click", paper_del);
}
function rock_del(){
document.getElementById("img-scissors").innerHTML = "";
document.getElementById("img-paper").innerHTML = "";
}```