url(image loacation) give a class
var basePath = 'mysite/images/';
$('a').each(function() {
var className = $(this).attr('class');
className = className.replace(/[^f][^0-9]*/, '').replace(' ', '');
$(this).css('background-image', basePath + className + '.png');
});