SwapOnscreenPhotosという関数呼び出しがあります。その関数のソースは次のとおりです。
function SwapOnscreenPhotos(currentPhotoSet, arrowClicked)
{
$("#photo-list img").each(function(index)
{
$(this).attr("src", photoData[currentPhotoSet][index].url);
if (photoData[currentPhotoSet][index].liked === true)
{
$(this).addClass("liked");
}
else
{
$(this).removeClass("liked");
}
});
//Animate the old photos off of the screen
$("#match").hide("slide", { direction: "left" }, 1000);
}
私はいくつかのランダムなことを行い、関数の最後で、無条件に#matchのエフェクトを呼び出したいと思います。このエフェクトを実行したいイベントはありません(重要な場合は、イベントによって、最初にSwapOnScreenPhotosを呼び出すかどうかが決まります)。この効果をどのように実行するのですか?
編集:
申し訳ありませんが、はっきりさせておきます。私は、すべてのjQuery式が同様の式に従っているという印象を受けました。$('selector').event(function() { //function stuff});
私のコード$("#match").hide("slide", { direction: "left" }, 1000);
はこの例から大きく外れています。私のコードは、次のモデルにより似ています$('selector').function
。コードをいつ実行するか、いつ実行しないかを指示するイベントがないことに注意してください。このイベントなしでjQuery関数を呼び出す方法はありますか?上記のコードを実行しようとすると、次のエラーが発生します。
Uncaught TypeError:オブジェクト#のプロパティ'#'は関数ではありませんjquery.js:8780 Tween.run jquery.js:8780 tick jquery.js:8491 jQuery.fx.timer jquery.js:9032 Animation jquery.js:8555 jQuery .fn.extend.animate.doAnimation jquery.js:8871 jQuery.extend.dequeue jquery.js:1894 jQuery.fn.extend.queue jquery.js:1937 jQuery.extend.each jquery.js:611 jQuery.fn.jQuery .each jquery.js:241 jQuery.fn.extend.queue jquery.js:1930 jQuery.fn.extend.animate jquery.js:8881 jQuery.each.jQuery.fn。(匿名関数)jquery.js:8853 AnimateMatch match .js:21 SwapOnscreenPhotos match.js:70 $ .ajax.success match.js:167 jQuery.Callbacks.fire jquery.js:974 jQuery.Callbacks.self.fireWith jquery.js:1082 done jquery.js:7650jQuery。 ajaxTransport.send.callback
このエラーは、イベントを指定できなかったことが原因であると考えました。これはもっと意味がありますか?ありがとうございました