Javascript Jquery在我的网站上不起作用

Javascript Jquery在我的网站上不起作用,javascript,jquery,html,Javascript,Jquery,Html,我有这个jquery代码,但由于某种原因它不起作用。我在JSFIDLE中测试了代码,效果很好。为什么在我的页面中不起作用。我在谷歌上搜索过类似的问题,但没有一个能帮助我确定问题所在 我在头部添加了Jquery作为 <script src="//code.jquery.com/jquery-1.11.0.min.js"></script> <script src="//code.jquery.com/jquery-latest.min.js"></

我有这个jquery代码,但由于某种原因它不起作用。我在JSFIDLE中测试了代码,效果很好。为什么在我的页面中不起作用。我在谷歌上搜索过类似的问题,但没有一个能帮助我确定问题所在

我在头部添加了Jquery作为

  <script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
  <script src="//code.jquery.com/jquery-latest.min.js"></script>

这里是html部分

<select id="2t2" style="">
  <option value="0"></option>
  <option value="1">1%</option>
  <option value="2">2%</option>
  <option value="3">3%</option>
  <option value="4">4%</option>
  <option value="5">5%</option>
</select>

<select id="2t3" style="">
  <option value="0"></option>
  <option value="1">1%</option>
  <option value="2">2%</option>
  <option value="3">3%</option>
  <option value="4">4%</option>
  <option value="5">5%</option>
</select>

1%
2%
3%
4%
5%
1%
2%
3%
4%
5%
这是Jquery代码

<script type='text/javascript'> 
  var i=$('#2t2'),x=$('#2t3'),a,b;
  $(i).change(function(){
    a=i[0]; b=x[0];
    if(a.selectedIndex>b.selectedIndex) {
       b.selectedIndex = a.selectedIndex;
     }
    });
 $(x).change(function(){
   a=i[0]; b=x[0];
    if(b.selectedIndex<a.selectedIndex) {
     a.selectedIndex = b.selectedIndex;
    }
   });
 </script>

变量i=$('2t2'),x=$('2t3'),a,b;
$(i).更改(函数(){
a=i[0];b=x[0];
如果(a.selectedIndex>b.selectedIndex){
b、 selectedIndex=a.selectedIndex;
}
});
$(x).更改(函数(){
a=i[0];b=x[0];

如果(b.selectedIndex为什么使用两个版本,这将产生冲突,请删除第一个包含,仅使用:

<script src="//code.jquery.com/jquery-latest.min.js"></script>

1%
2%
3%
4%
5%
1%
2%
3%
4%
5%

为什么使用两个版本会产生冲突,请删除第一个版本,仅使用:

<script src="//code.jquery.com/jquery-latest.min.js"></script>

1%
2%
3%
4%
5%
1%
2%
3%
4%
5%
使用这两行

<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="//code.jquery.com/jquery-latest.min.js"></script>
我还发现以下故障:

var i=$('#2t2')
已经是jQuery对象。请更改行

$(i).change(function(){

对变量x执行相同的操作。

使用这两行

<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="//code.jquery.com/jquery-latest.min.js"></script>
我还发现以下故障:

var i=$('#2t2')
已经是jQuery对象。请更改行

$(i).change(function(){


对变量x执行相同操作。

定义“不工作”。这看起来是错误的:
@miparnisari no这是正确的,当您以
/
作为前缀时,它将使用与您从中查看它的页面相同的协议。因此,根据您的站点是http还是https,它将正确地使用https或http。当您从本地文件系统查看html时,这将导致问题,因为协议是
fi乐://
@mash,啊,对了,我不知道:)谢谢!好像应该定义“不工作”。这看起来是错误的:
@miparnisari no这是正确的,当您以
/
作为前缀时,它将使用与您从中查看它的页面相同的协议。因此,根据您的站点是http还是https,它将正确地使用https或http。当您从本地文件系统查看html时,这将导致问题,因为协议是
fi乐://
@mash,啊,对了,我不知道:)谢谢!看起来应该只有
但没有运气。感谢使用reay函数,检查我的更新。
只有但没有运气。感谢使用reay函数,检查我的更新。