Created
July 28, 2014 04:44
-
-
Save dstyle0210/6f3b954106726d2f1473 to your computer and use it in GitHub Desktop.
이미지 랜덤으로 뿌리기, 단 이전 이미지를 기억하여 똑같이 보이지는 않도록.
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
| //<![CDATA[ | |
| $(function(){ | |
| var $wrap = $("#js-section0101"); | |
| var imageArr = ["/asan/images/main/section0101_bg.png", "/asan/images/main/section0101_bg2.png", "/asan/images/main/section0101_bg3.png"]; | |
| var oldNum; | |
| var num = ~~(Math.random()*imageArr.length); | |
| if(window.localStorage){ | |
| oldNum = Number(window.localStorage.getItem('section0101_ranomNum')); | |
| while(oldNum === num){ | |
| num = ~~(Math.random()*imageArr.length); | |
| } | |
| } | |
| window.localStorage && window.localStorage.setItem('section0101_ranomNum', num); | |
| $wrap.css("background-image", "url("+imageArr[num]+")"); | |
| }); | |
| //]]> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment