jquery文字闪动效果实例
jquery文字闪动效果,实现原理:
1,先要获取到最新一条记事的pid,这个pid可以是后台给你接口中返回的值。
2,在添加成功后来闪动这条记事,
3,闪动的方法可以写到函数里,直接调用。
4,有闪动就要有定时器,开启定时器就要关闭定时器。
例子,在页面打开的时候闪动。
<!DOCTYPE HTML>
<html>
<head>
<title>闪动提示</title>
<style>
*{ margin:0; padding:0;}
.box{color: #000}
.red{color:#d00;}
</style>
<script type="text/javascript" src="jquery-1.11.1.min.js"></script>
<script>
function shake(element,className,times){
var i = 0,
t = false ,
o = element.attr("class"),
c = "",
timestimes = times||2;
if(t) return;
t = setInterval(function(){
i++;
c = i%2 ? o + ' ' + className : o;
element.attr("class",c);
if(i==2*times){
clearInterval(t);
element.removeClass(className);
}
},200);
};
$(function(){
//domready 就闪动
shake($(".box"),"red",3);
});
</script>
</head>
<body>
<div class="box">打开就闪动</div>
</body>
</html>
以下代码在提示两种点击闪动,和不同校验闪动,如form表单输入错误的闪动。
$("#box1").bind({
click:function(){
shake($(this),"red",3);
return false;
}
});
//通不过mail校验闪动
$("#mail").blur(
function(){
if(!/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/.test($(this).val())) {
shake($(this),"red",3);
}
}
);
您可能感兴趣的文章:
jquery文字闪动效果实例
JS函数实现网页标题(title)闪动效果
js实现网页标题闪烁效果
photoshop利用分层云彩快速制作闪电效果教程
js实现网页标题栏的闪烁效果(示例)
让新消息在网页标题闪烁提示的jQuery代码
网页标题title闪动提示效果实现方法
photoshop设计金光闪闪的金色金属字制作教程
photoshop三招快速制作聊天动态文字教程分享
Illustrator创建精致闪亮的长投影宝石制作教程