<?php
// In your theme's template.php file:

function MYTHEME_preprocess_page(&$variables) {
drupal_add_js('jQuery.extend(Drupal.settings, { "pathToTheme": "' . path_to_theme() . '" });', 'inline');
}


// In your theme's js file

 $('#IMG').attr('src', Drupal.settings.basePath + Drupal.settings.pathToTheme + '/PATH/TO/SOME/FILE.png');
 
 // Source: https://drupal.org/node/1427564