这是一题知名公司的前端开发面试试题,要求写出闪光字的效果。基本思路是:
1.页面中可能多出使用;
2.选出几种颜色;
3.选择合理的跳动时间。
例如html代码
[code=”html”]
前端开发
https://www.html.cn
[/code]
javascript代码:
[code=”javascript”]
function MagicColor(elem,colors,interTime){
this.elements=elem||[];
this.colors=colors||[“#CC0000″,”#CC6D00″,”#CCCC00″,”#00CC00″,”#0000CC”,”#00CCCC”,”#CC00CC”];//可选的颜色值
this.indexColors=0;//颜色值索引
this.interTime=interTime;//跳动的间隔时间
}
MagicColor.prototype.timerCall=function(){
var elem=this.elements,cls=this.colors;
var color=this.colors[(this.indexColors++) % this.colors.length];//去除当前颜色
for(var i=0;i
建议添加demo页面。
才接触前端开发,不知道楼主的这些代码是在什么工具里写的?