2

このスクリプトを追加しました

<script type="text/javascript">
    var x = 2;
//console.log('Not broken');
$('.email_image li:gt(0)').css({opacity:0});

setInterval(function() { // function slideshow() { var m = $('.email_image li').size(); x += 1; console.log('Not broken'); if (x > m) { x = 1; } $(".email_image ul li:visible").animate({ opacity: 0 }); $(".email_image ul li:nth-child(" + (x) + ")").animate({ opacity: 1 }); // } }, 5000); </script>

私のテンプレートのindex.phpに。スクリプトを使用して、一連の画像の簡単なスライドショーを作成したいと考えています。ループは 1 回だけ実行され、停止します。Joomlaの外では完全に機能しますが、Joomlaでは一度実行して停止します。Joomla には setInterval 関数に問題がありますか。この問題を回避する方法は何ですか?

Joomla 内のデモと Joomla 以外のデモへのリンクを次に示します。 Joomla のデモ 外部 Joomla のデモ

4

1 に答える 1

1

jQueryパスは正しく、含まれていますが$、jQuery以外のものを返します(競合のようです):

function $(el){if(!el)return null;if(el.htmlElement)return Garbage.collect(el);if([window,document].contains(el))return el;var type=$type(el);if(type=='string'){el=document.getElementById(el);type=(el)?'element':false;}
if(type!='element')return null;if(el.htmlElement)return Garbage.collect(el);if(['object','embed'].contains(el.tagName.toLowerCase()))return el;$extend(el,Element.prototype);el.htmlElement=function(){};return Garbage.collect(el);}

コンソールに表示されるエラーは次のとおりです。

Uncaught TypeError: Cannot call method 'css' of null

$jQuery の場合、 の各インスタンスをに置き換えてみてくださいjQuery

$または、次のようにすることもできます。

(function($){
   // your code here
})(jQuery);
于 2012-04-23T11:28:25.817 に答える