2011-11-29 60 views
2

我有一个jQuery插件tzineClock。但是当我试图叫它jquery函数不支持

$(document).ready(function(){ 
    /* This code is executed after the DOM has been completely loaded */ 
    $('#fancyClock').tzineClock(); 
}); 

它是抛出错误为“此功能不支持”。任何人都可以告诉我错误可能是什么?这是tzineClock代码:

$.fn.tzineClock = function(opts){ 

     // "this" contains the elements that were selected when calling the plugin: $('elements').tzineClock(); 
     // If the selector returned more than one element, use the first one: 

     var container = this.eq(0);  
     if(!container) 
     { 
      try{ 
       console.log("Invalid selector!"); 
      } catch(e){} 

      return false; 
     } 

     if(!opts) opts = {}; 

     var defaults = { 
      /* Additional options will be added in future versions of the plugin. */ 
     }; 

     /* Merging the provided options with the default ones (will be used in future versions of the plugin): */ 
     $.each(defaults,function(k,v){ 
      opts[k] = opts[k] || defaults[k]; 
     }) 

     // Calling the setUp function and passing the container, 
     // will be available to the setUp function as "this": 
     setUp.call(container); 

     return this; 
    } 
+0

哪个功能?当你试图打电话给tzineClock?你能告诉我们调用它的代码吗? – Rup

+0

$(文件)。就绪(函数(){ \t/*这个代码在DOM之后执行已被完全装入*/ \t $( '#fancyClock')tzineClock(); }); – Nagarajan

+0

我只在这里打电话 – Nagarajan

回答

4

这很可能是因为jQuery尚未加载tzineClock函数,因此它“不受支持”。

检查您引用该插件的脚本标记,并确保tzineClock脚本标记在之前出现jQuery之一。

如果这没有什么区别,你可以给我们线文件这是造成误差,保证脚本文件使用任何浏览器的开发者工具实际上已经加载。

+0

这是正确的,顺序应该是'$ .fn.tzineClock = function(opts){/ * ... * /}'后跟'$(document).ready(function(){$('#fancyClock' ).tzineClock();});' –