问题描述
我有以下代码尝试在按下按钮后更改文本的背景色.情况是,它没有按照计划进行.这是为什么?这里出了什么问题.
I have the following code trying to change the background color of a text after pressing a button. The case is that it is not doing what it is intended to do. Why is that? What is going wrong here.
HTML代码
<html>
<head>
<script type="text/javascript" src="jquery-1.6.4.js"></script>
<script type="text/javascript" src="script.js"></script>
<script type="text/javascript" src="js/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.16.custom.min.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>
</div>
</html>
script.js
$("#bgcolor").click(function(){
$("#name").animate(
{backgroundColor: '#8B008B'},
"fast");}
);
编辑
我想注意到我有一个名为jquery-ui-1.8.16.custom的文件夹,这是我将这些文件放入其中的位置.而且,我已经引用了jquery-1.6.4,js,如下所示除了引用当前文件夹中js文件夹中的jquery-ui-1.8.16.custom.min.js之外,我还位于同一文件夹中.
I want to notice that I have a folder called: jquery-ui-1.8.16.custom, and this is where I'm putting these files in. And, I have referenced jquery-1.6.4,js as shown above which I also have it in the same folder, in addition to referencing jquery-ui-1.8.16.custom.min.js which is in the js folder in the current folder.
我在这里弄错了什么?这不是引用jQuery和jQueryUI的方法吗?
What am I getting wrong here? Isn't this the way to reference jQuery and jQueryUI?
使用的浏览器: Mozilla Firefox 6.0.2
Browser used: Mozilla Firefox 6.0.2
文件夹结构:
jquery-ui-1.8.16.custom/abc.html
jquery-ui-1.8.16.custom/abc.html
jquery-ui-1.8.16.custom/script.js
jquery-ui-1.8.16.custom/script.js
jquery-ui-1.8.16.custom/jquery-1.6.4.js
jquery-ui-1.8.16.custom/jquery-1.6.4.js
jquery-ui-1.8.16.custom/js/jquery-ui-1.8.16.custom.min.js
jquery-ui-1.8.16.custom/js/jquery-ui-1.8.16.custom.min.js
谢谢.
推荐答案
<script type="text/javascript" src="jquery-1.6.4.js"></script>
<script type="text/javascript" src="script.js"></script>
<script type="text/javascript" src="js/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.16.custom.min.js"></script>
参考点是否正确?删除引用后,它正在 jsfiddle 上工作.
Are the references point correct path? It is working on jsfiddle after removing the references.
这篇关于jQuery-背景颜色不变的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!