Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

156
Views
Javascript addEventListener click Event doesn't work

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 = "";
}```
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!