[javascript]代码库
目标:像新浪微博内容输入框的效果
特别注意:使用setTime调用函数的时候,字符串要加上引号,数字不用加;因为没有给字符串加引号导致:
Uncaught SyntaxError: Unexpected token ILLEGAL 没有捕获的语法错误:意外的标记是非法的
function fnErrorFlash(selector, times, errorcolor, normalcolor, delaytime) {
$(selector).css("background-color", errorcolor);
times = times - 1;
setTimeout("normalFlash('" + selector + "'," + times + ",'" + errorcolor + "','" + normalcolor + "'," + delaytime + ")", delaytime);
}
function normalFlash(selector, times, errorcolor, normalcolor, delaytime) {
$(selector).css("background-color", normalcolor);
if (times < 0) {
return;
}
times = times - 1;
setTimeout("fnErrorFlash('" + selector + "'," + times + ",'" + errorcolor + "','" + normalcolor + "'," + delaytime + ")", delaytime);
}