Last active
August 29, 2015 14:06
-
-
Save ederduran/8949e5978f05fca08d59 to your computer and use it in GitHub Desktop.
Pequeño plugin jQuery para backgrounds aleatorios - con jQuery 1.11.0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (function(e){$.fn.extend({backgroundRdm:function(e){this.each(function(){backgroundsTotal=e.length;random=Math.floor(Math.random()*backgroundsTotal+0);finalBack=e[random];$(this).css("background-image","url("+finalBack+")")})}})})(jQuery) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $(document).ready(function(){ | |
| //Asignamos a body un background aleatorio tomando en cuenta la lista de backgrounds que le pasamos a traves de un array | |
| $("body").backgroundRdm([ | |
| 'http://ederduran.com/wp-content/uploads/2014/09/square_bg.png', | |
| 'http://ederduran.com/wp-content/uploads/2014/09/pat-17.png', | |
| 'http://ederduran.com/wp-content/uploads/2014/09/gplaypattern.png', | |
| 'http://ederduran.com/wp-content/uploads/2014/09/light_wool.png', | |
| 'http://ederduran.com/wp-content/uploads/2014/09/grey.png', | |
| 'http://ederduran.com/wp-content/uploads/2014/09/ecailles.png', | |
| 'http://ederduran.com/wp-content/uploads/2014/09/cream_pixels.png', | |
| 'http://ederduran.com/wp-content/uploads/2014/09/crossword.png', | |
| 'http://ederduran.com/wp-content/uploads/2014/09/transp_bg.png', | |
| ]); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment