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
how to use onClick event handler in insertAdjacentHTML method

I am trying to add an onClick handler in insertAdjacentHTML method but getting SyntaxError: Function statements require a function name error, I have set a console log, it should show the console value but it throws the error,

Am I missing anything?

            document
              .querySelector(`[data-msgid="${view.id}"] .chat-msg__message`)
              ?.insertAdjacentHTML(
                'beforeend',
                `<div class="daisy-dropdown daisy-dropdown-end">
            <button tabindex="0" type="button">
              <i class="fa fa-bars ml-2"></i>
            </button>
            <div tabindex="0" class='${[
              'daisy-dropdown-content',
              'daisy-menu',
            ].join(' ')}'>
                <button onclick=${() => console.log('click')}>Kick</button>
            </div>
          </div>`              
);
about 4 years ago · Santiago Gelvez
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!