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

398
Views
how to fix this onclick error?? (javascript)

i was following youtube tutorial for deleting messages in chat and i did the same thing as he did and onclick doesnt work for me

const newMessage = ref(database, 'messages/');
        
function deleteMessage(self){
    console.log("test");
}
onChildAdded(newMessage, (data) =>  {
    let string = data.val().message;
    string = string.replaceAll("<", "&lt").replaceAll(">", "&gt");
    let msgDiv = '<message>\n' + data.val().time + " / " + data.val().name + ": " + string + '<delete>' + '<button onclick="deleteMessage(this);">' + '<span class="iconify" data-icon="ant-design:delete-filled"></span>' + 'Usuń' + '</button>' + '</delete>' + '</message>'
    let messages = document.querySelector("messages");
    messages.innerHTML += msgDiv;
})

i got: Uncaught ReferenceError: deleteMessage is not defined at HTMLButtonElement.onclick ((index):1:1)

any solutions?

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!