2012-01-11 43 views
0

我试图让我的代码的HTML和一些reasong当我尝试运行我的HTML文档中的代码,这是行不通的,但我对http://jsfiddle.net 尝试相同的代码和我的代码,它正在http://jsfiddle.net/gPfBC/我的动画进度条不起作用?

有人可以尝试这个代码,并把它给我的完整的HTML代码?

<head> 
    <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/> 
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script> 
    <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script> 

    <script> 
    $(document).ready(function(){ 
    var p=0; 

    $("#myProgressBar").progressbar({value:0}); 
     var timer = setInterval(function(){ 
      //This animates the bar 
      $("#myProgressBar .ui-progressbar-value").animate({width: p+"%"}, 500); 
      //This does static sets of the value 
      //$("#myProgressBar").progressbar("option","value",p); 
      p = p +3; 
      if(p>33.33){ 
       $("#myProgressBar .ui-progressbar-value").animate({width: "33.33%"}, 500); 
       //$("#myProgressBar").progressbar("option","value",100); 
       clearInterval(timer); 
      } 
    },500); 
}); 
    </script> 
    <style type="text/css"> 
    </style> 
</head> 
<body style=" background:url(ebay-bar/images/1.jpg) top left no-repeat; width:1099px; height:1050px;"> 
<a href="2.html" style="width:185px; height:31px;position:absolute; left: 198px; top: 516px;"></a> 
<div style="width:954px; position:absolute; top:606px; left: 67px; height: 45px;"> 
<div id="myProgressBar" style="height:43px;"></div> 
</div> 
</body> 
</html> 

回答

1

您正在jsFiddle上运行jQuery 1.3.2和jQuery UI 1.7.2脚本,但您的html页面已包含jQuery 1.5。

更换

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script> 

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> 

你的脚本可能使用的是已被弃用的jQuery的1.5或存在的jQuery 1.5和jQuery UI 1.8之间的一些问题的功能。尝试使用jQuery和jQuery UI的最新版本。

+0

非常感谢你,你完全正确!我没有话要带你!我在这里疯了:P – karlelizabeth 2012-01-11 07:58:50