Question 31
Which DOM method attaches an event handler function to an element without overwriting existing handlers?
addEventListener() attaches an event handler to the specified element without overwriting existing event listeners.
Which DOM method attaches an event handler function to an element without overwriting existing handlers?
addEventListener() attaches an event handler to the specified element without overwriting existing event listeners.
Which method cancels the default action associated with an event in JavaScript (e.g., preventing form submission)?
preventDefault() cancels the default behavior of an event (like preventing a form submit or link navigation).
Which method selects the first element within the document that matches a specified CSS selector?
document.querySelector() returns the first Element within the document that matches the specified selector.
What type of data structure is returned by document.querySelectorAll() in JavaScript?
querySelectorAll() returns a static NodeList representing a list of the document's elements that match the specified group of selectors.
Which DOM property returns or sets the text content of a node and its descendants without parsing the content as HTML?
textContent returns or sets the text content of a node and its descendants without interpreting the content as HTML.