Skip to content

Instantly share code, notes, and snippets.

/fixedcode.diff Secret

Created July 26, 2017 09:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/0ec5445ae61caafe55b259ba3beba1ce to your computer and use it in GitHub Desktop.
Save anonymous/0ec5445ae61caafe55b259ba3beba1ce to your computer and use it in GitHub Desktop.
- $(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