Qus : What is the correct way to change the background color of an element using DOM manipulation?
QusDOM हेरफेर का उपयोग करके किसी तत्व की पृष्ठभूमि का रंग बदलने का सही तरीका क्या है?
A. element.background = "red"; B. element.style.backgroundColor = "red";
C. element.style.background = "red"; D. element.css.backgroundColor = "red";
Solution
B. element.style.backgroundColor = "red";
Explanation
To change the background color of an element using JavaScript, you need to use the style property and specify the backgroundColor attribute.