- Create Reference
- Access Current Element
- Add Class
- Remove Class
- Toggle Class
- Check Class
- Set Style
- Get Style
- Set Attribute
- Get Attribute
- Remove Attribute
- Set Inner HTML
- Get Inner HTML
- Set Text Content
- Get Text Content
- Add Event Listener
- Remove Event Listener
- Focus Element
- Blur Element
- Scroll Into View
- Set Value (for form elements)
- Get Value (for form elements)
Action: Initialize a ref to be attached to a DOM element.
Code Snippet: const dropContainer = useRef(null);
Action: Retrieve the current DOM element.
Code Snippet: const element = dropContainer.current;
Action: Add a class to the element.
Code Snippet: dropContainer.current.classList.add('your-class-name');
Action: Remove a class from the element.
Code Snippet: dropContainer.current.classList.remove('your-class-name');
Action: Toggle a class on the element.
Code Snippet: dropContainer.current.classList.toggle('your-class-name');
Action: Check if the element has a specific class.
Code Snippet: dropContainer.current.classList.contains('your-class-name');
Action: Set an inline style property.
Code Snippet: dropContainer.current.style.color = 'red';
Action: Get an inline style property.
Code Snippet: const color = dropContainer.current.style.color;
Action: Set an attribute on the element.
Code Snippet: dropContainer.current.setAttribute('id', 'new-id');
Action: Get the value of an attribute from the element.
Code Snippet: const id = dropContainer.current.getAttribute('id');
Action: Remove an attribute from the element.
Code Snippet: dropContainer.current.removeAttribute('id');
Action: Set the HTML content inside the element.
Code Snippet: dropContainer.current.innerHTML = '<p>New Content</p>';
Action: Get the HTML content inside the element.
Code Snippet: const html = dropContainer.current.innerHTML;
Action: Set the text content inside the element.
Code Snippet: dropContainer.current.textContent = 'New Text';
Action: Get the text content inside the element.
Code Snippet: const text = dropContainer.current.textContent;
Action: Add an event listener to the element.
Code Snippet: dropContainer.current.addEventListener('click', handleClick);
Action: Remove an event listener from the element.
Code Snippet: dropContainer.current.removeEventListener('click', handleClick);
Action: Set focus on the element.
Code Snippet: dropContainer.current.focus();
Action: Remove focus from the element.
Code Snippet: dropContainer.current.blur();
Action: Scroll the element into view.
Code Snippet: dropContainer.current.scrollIntoView();
Action: Set the value of a form element (like an input or textarea).
Code Snippet: dropContainer.current.value = 'new value';
Action: Get the value of a form element (like an input or textarea).
Code Snippet: const value = dropContainer.current.value;