繁体   English   中英

我如何在jQuery中的页面加载时播放动画,以便它播放index.php而不播放other_page.php

[英]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

我想在页面加载时播放动画,但只对我的index.php播放,而不对网站的其他页面播放。

jQuery是否有类似这样的内容:

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

如果没有,我怎么能达到预期的效果?

只需使用以下任何jquery加载函数将jQuery代码放入index.php页面即可。

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

要么

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

要么

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

这样,您的动画将仅在index.php页面上运行,而不在其他任何页面上运行。

希望这能解决您的问题。

您可以使用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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM