How To Give Url For Images In $('.div').css('background-Image','url()');

Hi,

This is my folder structure public_html\themes\bootstrap.

Under bootstrap folder css,js,img are subfolders.

From file.js


$('.footer').css('background-image','url(../img/realestate_hover.png)');

But the image is not showing. How to give the URL.

Thanks in advance

if this snippet in your js file , you should fetch it back from the view , but first you should hide it somewhere :





/**

 * This is the shortcut to Yii::app()->request->baseUrl

 * If the parameter is given, it will be returned and prefixed with the app baseUrl.

 */

function bu($url = null)

{

    static $baseUrl;

    if ($baseUrl === null)

        $baseUrl = Yii::app()->getRequest()->getBaseUrl();

    return $url === null ? $baseUrl : $baseUrl . '/' . ltrim($url, '/');

}




/**

 * This is the shortcut to Yii::app()->theme->baseUrl

 * If the parameter is given, it will be returned and prefixed with the app baseUrl.

 */

function tu($url = null)

{

    static $baseUrl;

    if ($baseUrl === null)

        $baseUrl = Yii::app()->theme->getBaseUrl();

    return $url === null ? $baseUrl : $baseUrl . '/' . ltrim($url, '/');

}






may be tu function is what you need :lol: :




  // hide it some where , in js or html section:

   var themeUrl = "<?php  echo tu();?>" ;


 // html:

  <div id="themeUrl" title="<?php echo tu();?>"></div>

 // then in your js file refer it :  $("#themeUrl").attr("title");