我的一些JS

1. 数字单个滚动显示(用了JQuery的选择器)

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>New Web Project</title>
		<script type="text/javascript" src="lib/jquery/jquery-1.4.2.min.js"></script>
		<script type="text/javascript">
			
			function rollString(){
				rollNumber("58045780", 0, "", "showInput", 50);
				unrollNumber("58045780", 0, "", "showInput2", 80);
			}
			
			function rollNumber(numString, s, v, id, dly){
				var showInput = document.getElementById(id);
				if (s == 10 || numString == ""){
					return;
				}
				showInput.value = v + "" + s;
				if (numString.charAt(0) == s) {
					numString = numString.substring(1);
					v = showInput.value;
					setTimeout("rollNumber('"+numString+"', 0, '"+ v + "', '"+id+"',"+dly+")", dly);
				} else {
					var s = s - 0 + 1;
					setTimeout("rollNumber('"+numString+"',"+s+",'"+v+"','"+id+"',"+dly+")", dly);
				}
			}
			function unrollNumber(numString, s, v, id, dly){
				var showInput = document.getElementById(id);
				if (s == 10 || numString == ""){
					return;
				}
				showInput.value = s + "" + v;
				if (numString.charAt(numString.length - 1) == s) {
					numString = "" + numString.substring(0, numString.length - 1);
					v = showInput.value;
					setTimeout("unrollNumber('"+numString+"', 0, '"+ v + "','"+id+"',"+dly+")", dly);
				} else {
					var s = s - 0 + 1;
					setTimeout("unrollNumber('"+numString+"',"+s+",'"+v+"','"+id+"',"+dly+")", dly);
				}
			}
		</script>
    </head>
    <body>
        <h1>New Web Project Page</h1>
		<input type="button" value=" Show " οnclick="javascript:rollString();" />
		<input type="text" id="showInput" value="" style="font-family:Verdana;font-size:20pt;font-weight:bolder;" />
		<input type="text" id="showInput2" value="" style="font-family:Verdana;font-size:20pt;font-weight:bolder;" />
    </body>
</html>
 

2.用JQuery的mouseover和mouseout方法来实现菜单等鼠标移入改变背景颜色时(animate动态渐变效果时, 须引入JQuery插件color ), 为避免快速移入移出产生的鼠标移出后仍多次闪动, 应该在背景颜色改变之前, 先把该幸免元素的动作先stop掉...

var c = '#000000';
var bg = '#eeeeee';
$('table div').mouseover(function(){
	$(this).stop().animate({
		'color':bg,
		backgroundColor:c
	}, 100);
}).mouseout(function(){
	$(this).stop().animate({
		color:c,
		backgroundColor:bg
	}, 500);
});

 

3. JQuery的animate和其它方法交叉执行时(如addClass, removeClass, text, val等等), 会失去顺序执行, 在此处用queue/dequeue方法解决

$('#div').click(function(){
	$(this).stop().animate({width:'0px'}, 2000);
	//在div完全隐藏后, 更换div的内容
	$(this).queue(function(){
		$(this).text('12312312311233333333');
		$(this).dequeue();
	});
	$(this).animate({width:'200px'}, 2000);
});
 

 

 

4.

 

 

5.

 

 

6.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值