Ver Mensaje Individual
  #8 (permalink)  
Antiguo 21/10/2011, 04:12
MACvsWINDOWS
 
Fecha de Ingreso: enero-2011
Mensajes: 158
Antigüedad: 13 años, 3 meses
Puntos: 2
Respuesta: A ver si me podéis ayudar.

Nada, no hay manera, pongo el código de ejemplo con el que estoy trabajando a ver dónde están los errores.

archivo index.html

Código HTML:
<html>
<head>
<script src="bg.js" type="text/javascript"></script>
</head>
<body>
<img src="m_f1.png" class="background">
<img src="m_f2.png" class="background">
<img src="m_f3.png" class="background">
</div>
</body>
</html> 
archivo bg.js

Código HTML:
$(".background").click(function(event){
var srcImagen = $(this).attr('src');
$("#body").attr("style", "background-image: url(" + srcImagen+ ")");
}