【发布时间】:2011-11-29 03:31:15
【问题描述】:
我正在尝试使用jQuery 在按下按钮时更改<div> 部分的背景颜色,下面是执行此操作的代码。为什么它不起作用?
HTML 文件
<html>
<head>
<script type="text/javascript" src="jquery-1.6.4.js"></script>
<script type="text/javascript" src="script.js"></script>
<style type="text/css">
#name{
background-color: #FFFFF2;
width: 100px;
}
</style>
</head>
<body>
<input type="button" id="bgcolor" value="Change color"/>
<div id="name">
Abder-Rahman
</body>
</html>
script.js
$("bgcolor").click(function(){
$("#name").animate(
{backgroundColor: '#8B008B'},
"fast");}
);
谢谢。
【问题讨论】:
标签: jquery jquery-animate