I need to change the css propery of left div if right div doesn't contain image.
<div class="wrapper">
<div class="pg-left-bar"></div>
<div class="pg-right-bar">
<img src="img.jpg">
</div>
</div>
If right div has no image then left div width should be change to 100% and margin removed from left div and change the display property of right div to none
I know how to change the css property using jquery only if i am looking for the element in same div
$('.pg-right-bar').has('img').css({ 'background-color': '#fff' });
But i am not sure how i can do this for the above senario.
Any help is appreciated
UPDATE
Jquery Code to achive this
if ( $('.pg-right-bar').has('img').length > 0 )
{
$('.pg-left-bar').css({ 'background-color': '#ccc' });
}
else
{
$('.pg-left-bar').css({ 'margin-right': '0px' });
$('.pg-left-bar').css({ 'width': '100%' });
$('.pg-right-bar').css({ 'display': 'none' });
}