[英]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. 我想在页面加载时播放动画,但只对我的index.php播放,而不对网站的其他页面播放。
Is there something like this for jQuery: 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. 只需使用以下任何jquery加载函数将jQuery代码放入index.php页面即可。
$(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. 这样,您的动画将仅在index.php页面上运行,而不在其他任何页面上运行。
Hope this will solve your problem. 希望这能解决您的问题。
You can check the url with Javascript and then fire your function to play 您可以使用Javascript检查网址,然后触发您要播放的功能
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>')
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.