gpt4 book ai didi

javascript - 从其他页面调用 slideDown()

转载 作者:行者123 更新时间:2023-11-30 08:47:34 27 4
gpt4 key购买 nike

我在 profile.php 中有一个可用的 slideDown div。当我单击用户名时,个人资料信息会向下滑动。这是结构,

profile.php - 这工作正常。

$('.showprofile').click(function() {
$('#userprofile').slideDown(1000);
});

我卡住的地方是,

我想在 users.php 上有一个链接

<a href='profile.php#userprofile'>

当我点击上面的链接时,我应该被带到 profile.php 页面,然后 userprofile div 应该自动向下滑动。

我怎样才能做到这一点?

最佳答案

只需将该代码添加到该页面的 $(window).load() 中,

<script>
$(document).ready(function(){
$(window).load(function(){
$('#userprofile').slideDown(1000);
});
});
</script>

注意,你应该在document.ready()中注册window.load(),因为可能有id为#userprofile的元素 页面加载后将不可用。

关于javascript - 从其他页面调用 slideDown(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20698018/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com