网站平台搭建怎么弄的,215做网站,如何学习网站制作,达内网站开发培训价格问题#xff1a; 我想点击按钮时把页面中的body颜色和button中颜色【同时】改变 这个时候出现了body颜色先变化#xff0c;而button颜色后变化#xff0c;似乎是因为我的代码是这样有先后顺序的#xff1a;
$(html,body).animate({backgroundColor:BGC[rando…问题 我想点击按钮时把页面中的body颜色和button中颜色【同时】改变 这个时候出现了body颜色先变化而button颜色后变化似乎是因为我的代码是这样有先后顺序的
$(html,body).animate({backgroundColor:BGC[randomColorNum]});
$(html,.button).animate({backgroundColor:BGC[randomColorNum]}); 要使body和button的背景颜色同时改变需要给animate()添加很短的延时
$(html,body).animate({backgroundColor:BGC[randomColorNum]},100);
$(html,.button).animate({backgroundColor:BGC[randomColorNum]},100); 按理说只要添加第一个js语句的延迟可是为什么要添加两个