Skip to content

Instantly share code, notes, and snippets.

@cron64
Created May 9, 2013 22:25
Show Gist options
  • Save cron64/5551081 to your computer and use it in GitHub Desktop.
Save cron64/5551081 to your computer and use it in GitHub Desktop.
JS: Cambiar Imagen
//DETECTAR ANCHO
var ancho;
if (document.body)
ancho = (document.body.clientWidth);
else
ancho = (window.innerWidth);
if (ancho<=770)
{
//Código de ejemplo...
$("#contenido img").attr("src",rutaImagen768);
}
//
$(window).resize(function () {
if($(window).width() <= 770){
$("#contenido img").attr("src",rutaImagen768);
}else{
$("#contenido img").attr("src",rutaImagen1024);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment