如何在jQuery中的页面加载上播放动画,以便它可以为index.php播放但不是 other_page.php

I want to play an animation on page load but only for my index.php and not for every other page of my website.

Is there something like this for jQuery:

$('index.php').ready(function());

?

If not how can I achieve the desired effect?

Just put your jQuery code in index.php page only using any of the following jquery load functions.

$(window).load(function(){...});

or

$(document).ready(function(){...});

or

$('body').onload(function(){...});

by this your animation will run only on index.php page and not any other page.

Hope this will solve your problem.

You can check the url with Javascript and then fire your function to play

if(
window.location.href=="address to check"
)
 your_function();
{
/* some code to load */
}else{
document.write('<div>testing my super loaded div code sample</div>')
}
}