editElement.addEventListener("click", ()=>{
textComment.setAttribute("disabled", true)
textComment.classList.add("uwu")
})
I am trying to add some attributes to my <textarea> from .js but I cannot make it work
CodePudding user response:
Using your code with a function instead of adding an eventlistener works.
function handleClick() {
const demoTextArea = document.querySelector('#demo');
demoTextArea.setAttribute('disabled', true);
console.log(demoTextArea);
}
<div>
<button onclick="handleClick()">disable input</button>
</div>
<textarea id="demo"> demo </textarea>
Here is a demo
