Search code examples
javascriptphpjqueryanimationpageload

How can I play an animation on page load in jQuery so that it plays for index.php but not e.g. 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?


Solution

  • 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.