function that disabled an element in javascript

To disable an element in JavaScript, you can use the disabled property of the DOM element. Here's an example function that disables an element:

index.tsx
function disableElement(elementId) {
  var element = document.getElementById(elementId);
  if (element) {
    element.disabled = true;
  }
}
141 chars
7 lines

The disableElement function takes an element ID as its parameter and gets a reference to the element using the getElementById method. If the element exists, it sets the disabled property to true.

gistlibby LogSnag