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

176
Views
How to use document.getElementById in inline click event binding?

The following code cannot be parsed by VS Code.

Parser Error: Missing expected ) at column 34 in [(document.getElementById('btnA') as HTMLInputElement).disabled=true] in

<button id="btnA">A</button>
<button (click)="(document.getElementById('btnA') as HTMLInputElement).disabled=true">Disable A</button>

or

<button id="btnA">A</button>
<button (click)="<HTMLInputElement>document.getElementById('btnA').disabled=true">Disable A</button>

How to use document.getElementById() in inline click event binding?

Edit 1:

I want to use event binding rather than onclick.

Edit 2:

Actually I want to mimic the working code below but with getElementById().

<button #btnA>A</button>
<button (click)="btnA.disabled=true">Disable A</button>
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

<button id="btnA">A</button>
<button onClick="() =>{<HTMLInputElement>document.getElementById('btnA').disabled=false"}>Disable A</button>
about 4 years ago · Juan Pablo Isaza Report

0

You can use a template reference, which will be a reference to the HTML element

<button #btnA>A</button>
<button (click)="btnA.disabled=true">Disable A</button>
about 4 years ago · Juan Pablo Isaza Report
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!