2011-11-29 62 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();});' –