Open In App

Web technologies Questions | jQuery Quiz | Set-1 | Question 2

Which of the following is the correct syntax to set the background color of all h1 elements to Green in jQuery?

(A)



$(\”h1\”).html(\”background-color\”,\”Green\”);

(B)



$(\”h1\”).layout(\”background-color\”,\”Green\”);

(C)

$(\”h1\”).style(\”background-color\”,\”Green\”);

(D)

$(\”h1\”).css(\”background-color\”,\”Green\”);

Answer: (D)
Explanation:

Here $ target the h1 element in jQuery, with the help of the css we can set the style of an HTML element. The correct syntax for setting the background color to Green of an h1 element is – $(“h1”).css(“background-color”,”Green|”);

Quiz of this Question
Please comment below if you find anything wrong in the above post

Article Tags :