Home »
MCQs »
jQuery MCQs
Which is the correct jQuery statement to change the color of all <p> elements which are sibling elements of <pre>?
96. Which is the correct jQuery statement to change the color of all <p> elements which are sibling elements of <pre>?
- $("#pre").siblings("p").css({"color": "red"});
- $(".pre").siblings("p").css({"color": "red"});
- $("pre").siblings(".p").css({"color": "red"});
- $("pre").siblings("p").css({"color": "red"});
Answer: D) $("pre").siblings("p").css({"color": "red"});
Explanation:
The correct jQuery statement to change the color of all <p> elements which are sibling elements of <pre> is:
$("pre").siblings("p").css({"color": "red"});