的JavaScript/ASP - 不工作

问题描述:

我必须找错了,但我找不到窍门:的JavaScript/ASP - 不工作

 <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent"> 
<script src="http://code.jquery.com/jquery-1.4.2.min.js" type="text/javascript"></script> 
     <script src="http://www.listinventory.com/js/jquery-ui-1.8.1.custom.min.js" type="text/javascript"></script> 
     <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script> 
     <script type="text/javascript" src="http://code.google.com/p/jquery-utils/source/browse/trunk/src/jquery.countdown.js"></script> 
<script type="text/javascript"> 
     $(function hello() { 
      // function that does something exciting? 
      var liftOff = function() { 
       // .... 
      }; 

      // Get a date that is some (short) time in the future 
      var getDeadline = function() { 
       var shortly = new Date(); 
       shortly.setSeconds(shortly.getSeconds() + 5.5); 
       return shortly; 
      }; 

      // Attach click handler to all our buttons 
      $("div.mainpanel button.resetButton").click(function (event) { 

       // I am assuming that you will not be nesting these controls? 
       var $mainpanel = $(this).parents("div.mainpanel") // this will find the mainpanel div that contains the pressed button 
       .effect("highlight", {}, 700); 

       $("div.shortly", $mainpanel) // this will find any div with the class = shortly inside mainpanel 
       .countdown('change', { until: getDeadline() }); 
      }); 

      // Start all countdowns going on page load 
      $('#shortly').countdown({ 
       until: getDeadline(), 
       onExpiry: liftOff, 
       layout: '{sn}' 
      }); 
     }); 

</script> 


    <div class="mainpanel"> 
    <div> 
     test 
    </div> 
    <div class="shortly"> 

    </div> 
    <button class="resetButton"> 
     Reset 
    </button> 
</div> 

</asp:Content> 

我得到一个“Microsoft JScript运行时错误:对象不支持此属性或方法“倒计时的例外。

+0

控制台上是否有任何错误? – jigfox 2010-07-22 12:20:28

+1

显示倒计时代码请 – 2010-07-22 12:31:09

+0

如果错误处于倒数计时,我们需要相应的代码,甚至更好,我们需要输出异常的行号! – jigfox 2010-07-22 12:44:45

您可以尝试从$(function hello() {删除“hello” 这不是必需的。

倒计时方法的代码在哪里?这是在一个JQuery插件或者它是你自己的功能?

+0

好吧,但我得到一个“Microsoft JScript运行时错误:对象不支持此属性或方法”异常。虽然我相信我得到了所有的jQuery脚本。 – Julian 2010-07-22 12:08:42

+0

定义倒计时方法在哪里? – 2010-07-22 12:09:18

+0

等待我将添加库网址,该方法应该在jquery.countdown.js – Julian 2010-07-22 12:11:11

$mainpanel是否有可能与其他内容相冲突?尝试将其重命名为其他名称(不含$)。

我认为它必须是你如何引用你的插件代码。我粘贴在线代码,它没有和错误的工作。

请参阅我的测试:http://jsfiddle.net/3UwCg/