Instructions

  • 1. Your final score will reflect your grasp of the concepts—approach each question with precision.
  • 2. Thoroughly review each solution before proceeding to ensure full understanding.
  • 3. Final results will be available after submission to provide insights into areas for further improvement.
  • 4. Maintain academic integrity—plagiarism undermines learning and professional growth.
  • 5. Once submitted, responses are final, so ensure you’re confident in your answers.
  • 6. These challenges are designed to test practical knowledge; apply your skills as you would in real-world scenarios.

All Problems

Question

Action

What method would you use to add a new class to an element?

View

How can you remove an attribute from an element?

View

What is the correct way to change the background color of an element?

View

Which of the following will remove an element from the DOM?

View

What does element.cloneNode(true) do?

View

How can you change the src attribute of an image element?

View

Which method can be used to append a new child element to a parent element?

View

How can you access the first child of a node?

View

What will element.style.display = 'none'; do?

View

Which method is used to change the text content of an element?

View

What method would you use to add a new class to an element?

element.addClass()
element.className += 'newClass';
element.classList.add('newClass');
Both b and c

How can you remove an attribute from an element?

element.removeAttribute('attributeName');
element.deleteAttribute('attributeName');
element.remove('attributeName');
element.removeAttr('attributeName');

What is the correct way to change the background color of an element?

element.style.backgroundColor = 'red';
element.style.background = 'red';
element.setAttribute('style', 'background-color:red;');
All of the above

Which of the following will remove an element from the DOM?

element.remove();
parentNode.removeChild(element);
element.innerHTML = '';
Both a and b

What does element.cloneNode(true) do?

Clones the element without children
Clones the element including its children
Copies the element's attributes
Both a and c

How can you change the src attribute of an image element?

image.src = 'newImage.jpg';
image.setAttribute('src', 'newImage.jpg');
Both a and b
image.changeSource('newImage.jpg');

Which method can be used to append a new child element to a parent element?

parentElement.appendChild(newElement);
parentElement.addChild(newElement);
parentElement.insertChild(newElement);
parentElement.insertBefore(newElement);

How can you access the first child of a node?

node.firstChild
node.childNodes[0]
node.firstElementChild
All of the above

What will element.style.display = 'none'; do?

Hide the element
Remove the element from the DOM
Change the element's color to none
None of the above

Which method is used to change the text content of an element?

element.innerHTML
element.textContent
element.setText()
Both a and b