Yo creo que es mas simple que eso..... algo asi:
Código HTML:
Ver original<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script type="text/javascript"> function rand(min, max){
var argc = arguments.length;
if(argc == 0){
min = 0;
max = 2147483647;
}else if(argc == 1){
return "Warning: rand() expects exactly 2 parameters, 1 given";
}
return Math.floor((Math.random() * (max - min + 1)) + min);
}
function change(){
aleatorio = rand(1, 30);
document.getElementById("back_change").rel = '../css/backgrounds/' + aleatorio + '.css';
document.getElementById("back_change").innerHTML = aleatorio;
}
<a id="back_change" href="#" onclick="change()" style="background:url(../images/paint-can.png) no-repeat; height:16px; width:16px;"></a>