function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SumitkSumitk 

How to write vanilla HTML in LWC HTML template?

In LWC we write HTML template to add event handler like this.
<template>
    <input type="text" value={myValue} onchange={handleChange} />
</template>
but I want to write this code just like in vanilla HTML like
<template>
    <input type="text" value={myValue} onchange=handleChange() />
</template>
My final HTML generated should be the same.
 
AnudeepAnudeep (Salesforce Developers) 
Hi Sumit - I read in this answer that you should be able to inject the raw HTML via Element.innerHTML. I suggest giving it a try
SumitkSumitk
Hi Anudeep,
Thanks for your response. I have gone through the solution but the generated HTML was not the same. I was able to assign ids that I want but I was unable to add event listeners to the elements. So it's not working as expected.