-
-
Save anonymous/0ec5445ae61caafe55b259ba3beba1ce to your computer and use it in GitHub Desktop.
This file contains 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(main); | |
- var main=function(){ | |
//颜色数组 | |
var colors = ['#16a085', '#27ae60', '#2c3e50', '#f39c12', '#e74c3c', '#9b59b6', '#FB6964', '#342224', "#472E32", "#BDBB99", "#77B1A9", "#73A857"]; | |
//设置new-speak点击事件 | |
$("#new-speak").on("click",function(){ | |
//获取随机数 | |
var random =Math.floor(Math.random() * 4),random1 =Math.floor(Math.random() * 11); | |
//获取json,并设置参数jd为json对象,成功后调用内部方法 | |
$.getJSON("https://api.myjson.com/bins/4ogzn",function(jd){ | |
//#text和#author一起淡入“slow”然后执行内部方法淡出(并提取了数据) | |
$("#text,#author").fadeOut("1000",function(){ | |
$("#text").html(jd.quotes[random].quote).fadeIn("1000"); | |
$("#author").html(jd.quotes[random].author).fadeIn("1000"); | |
}); | |
$("body").animate({background:"#"+colors[random1],color:"#"+colors[random1]},1000); | |
}) | |
}) | |
- } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment