Jquery按钮换色

编程有钱人了 2012-12-08 09:16:49
看代码

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>111111111111</title>
<script src="js/jquery-1.7.1.js" type="text/javascript"></script>
<script type="text/javascript">
function checkColor()
{
$("#Button2").css("background-color", "#00a0e9").delay(500).css("background-color", "#7ecef4");
}
</script>
</head>

<body>
<input id="Button1" type="button" value="button" onclick="checkColor()"/>
<input id="Button2" type="button" value="button" />

</body>
</html>

实现停顿换色的效果 怎么不行啊?求教啊
那个delay(500) 没作用
...全文
148 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
风一样的大叔 2012-12-08
  • 打赏
  • 举报
回复
此方法只能适用在动画之间做延迟效果,你要实现如你的效果,需要用
<!DOCTYPE html>
<html>
<head>
  <style>
div { position: absolute; width: 60px; height: 60px; float: left; }
.first { background-color: #3f3; left: 0;}
.second { background-color: #33f; left: 80px;}
</style>
  <script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
  
<p><button>Run</button></p>
<input id="Button2" type="button" value="button" />
<div class="first"></div>
<div class="second"></div>
        
<script>
    $("button").click(function() {
	$("#Button2").css("background","#00a0e9");
	 setTimeout(function(){ $("#Button2").css("background","#7ecef4");}, 500);
    });
</script>

</body>
</html>

87,991

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧