Question 44Asked in DSSSB TGT Computer Science (Technical), 12 Sep 2025, Shift 1 (9:00 AM)

Which of the following DHTML methods is used to change the style of an HTML element

Which of the following DHTML methods is used to change the style of an HTML element using CSS dynamically?
  1. Adocument.createElement("style")
  2. Bdocument.getElementById("element").setCSS()
  3. Celement.style.backgroundColor = "red"
  4. Dwindow.addEventListener("resize")
Show answerHide answer

Correct answer: (C) element.style.backgroundColor = "red"

Explanation

In DHTML, a style is changed at run time by assigning to the element's style object, e.g. element.style.backgroundColor = "red". There is no setCSS() method, and resize is an event, not a styling method.

From DSSSB TGT Computer Science PYQ (Technical), 12 Sep 2025, Shift 1 (9:00 AM)

This is question 44 of DSSSB TGT Computer Science PYQ (Technical), 12 Sep 2025, Shift 1 (9:00 AM). See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.