2014-01-20 86 views
0

我在創建一個joomla模板。 我在我的index.php加載的jQuery,此代碼:在joomla模板中調用.js文件

JHtml::_('jquery.framework'); 

,然後我創建了JS文件夾animate.js包括該腳本:

<script> jQuery("#content").ready(function(){ 

jQuery("#content").animate({opacity:'0.4'}); 

}); </script> 

和我說

<script type="text/javascript" src="templates/basicjoomla3.0template/js/animate.js"></script> 

在index.php的頭部分,但它不起作用。 當我在index php的body標籤中使用我的腳本時,它工作正常,但是當我想從js文件加載時它不起作用。 現在我該怎麼做? 感謝您的幫助。

回答

0

檢查您的animate.jsjquery loads後加載或試試這個,

PHP:

JHtml::_('jquery.framework', true, true); 
followed by your plugins: 
// some plugin located at _basePath/js 
JHtml::_('script',$this->_basePath.'js/animate.js', false, true, false, false); 

刪除script tagsanimate.js

jQuery("#content").ready(function(){ 
    jQuery("#content").animate({opacity:'0.4'}); 
}); 
+0

謝謝當我刪除腳本標記一個lot.it工作。 – Se7en

0

試試這個,你的文件路徑看起來錯

<script type="text/javascript" src="/templates/basicjoomla3.0template/js/animate.js"></script> 

而且,你不需要在標籤JS文件