# JQuery: Div background image scale

**URL:** <https://forum.kirupa.com/t/jquery-div-background-image-scale/327137>\
**Category:** web dev\
**Created:** [February 8, 2012, 11:31am UTC](https://forum.kirupa.com/t/jquery-div-background-image-scale/327137 "2012-02-08T11:31:40Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![nitinmukesh](https://avatars.discourse-cdn.com/v4/letter/n/7feea3/32.png) [@nitinmukesh](https://forum.kirupa.com/u/nitinmukesh)\
**Post date:** [February 8, 2012, 11:31am UTC](https://forum.kirupa.com/t/jquery-div-background-image-scale/327137/1 "2012-02-08T11:31:40Z")

</div>

,

I am using Jquery to add background image to a div which keeps changing on elements click.

The image is adding correctly but it is not occupying the whole div space due to smaller dimension. I would like the image to fit the div width height.

Could someone please help which property should I use to achieve this which should work on all browsers

This is the code I am using

> var image\_url = “url(”+\_xmlUnitObj.img+“) no-repeat left top”;  
> $(‘#rightMenu’).css(“background”, image\_url);

where \_xmlUnitObj.img contains the image path  
and rightMenu is the div id.
