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

123
Views
I apply addevent listener on multiple items and also make the content editable, but it didn't worked?

I am trying to make the note title editable when someone clicks on it. It worked when applied on a single note but its (contenteditable) function is not working on all elements. Here is the javascript code:

let notecardTitle = document.getElementsByClassName("cardtitle");
for(let i = 0 ; i < notecardTitle.length ; i++){
notecardTitle[i].addEventListener("click", function changeTitle(e) {
        console.log("change", e);
        notecardTitle.contentEditable = 'true';    
    });
}

I am applying this event-listener on this note which is also made in javascript

let showBox = "";
    noteData.forEach(function(element, index) {
        showBox += `<div class="noteCard my-2 mx-2 card" style="width: 18rem;">
                <div class="card-body">
                  <h5 class="cardtitle">Note 
                  ${index + 1}
                  </h5>
                  <p class="card-text"> 
                  ${element}
                  </p>
                  <button id="${index}" onclick="deleteNote(this.id)" class="btn btn-primary">Delete Note</a>
                </div>
              </div>   `
            })

Leave the NoteData line. This is the code on which i am applying event-listener <h5 class="cardtitle">Note

Thanks

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!