Question and answer is powered by AnsPress.io
I have to div.
One having id but doesn’t have
<div>first element</div> <div id="second">second element</div>
I want to add background color to first element respect to second one.
As you know jquery has a function .prev().
So the following code is
$.('#second').prev().css('''background-color','#f00');
Here first we are finding the previous div and then add background color using css method.