2009-05-26 133 views
2

我有一個javascript錯誤的問題:$("#slider") is undefinedJavascript undefined變量

我該如何解決這個問題?

<script type="text/javascript"> 
$(document).ready(function() { 
    $("#slider").easySlider({ 
     controlsBefore: '<p id="controls">', 
     controlsAfter: '</p>', 
     prevId: 'prevBtn', 
     nextId: 'nextBtn' 
    }); 
}); 
</script> 

這是我的HTML

<div id='slider'> 
    <table> 
     <tr> 
      <td width='325'>hello</td> 
      <td width='325'>hello</td> 
    </table> 
</div> 
+0

的順序請縮進你的腳本。還包括您正在使用的插件easySlider的URL。 – svinto 2009-05-26 13:26:33

+0

http://cssglobe.com/post/4004/easy-slider-15-the-easiest-jquery-plugin-for-sliding – djairo 2009-05-26 13:30:15

回答

2
jQuery(document).ready(function() { 
    jQuery("#slider").easySlider({ 
     controlsBefore: '<p id="controls">', 
     controlsAfter: '</p>', 
     prevId: 'prevBtn', 
     nextId: 'nextBtn' 
    }); 
}); 

Probebly你有更多然後1個jQuery腳本試試這個腳本,如果它工作,你必須改變腳本中使用

1

我懷疑有一個在你這裏粘貼代碼中的問題 - 即使你寫的東西是這樣的:

$('bladkhadlhadkjha').easySlider({ ... }); 

你止跌沒有得到「未定義」的錯誤,因爲jQuery會優雅地處理它。確保jQuery被正確包含,你的插件被正確包含,並且你粘貼的代碼正是你遇到問題的代碼。

1

嘗試:

$(document).ready(function(){ 
    alert("jquery is working"); 
}); 

如果不要讓一個警報彈出你的問題是在鏈接到jQuery的。 我希望它能幫助;)