gpt4 book ai didi

javascript - 使用新的 div 复制函数

转载 作者:太空宇宙 更新时间:2023-11-03 18:55:38 24 4
gpt4 key购买 nike

如何将此功能复制到另一个 div?

function goto(id, t){   

//animate to the div id.
$(".headbox-wrapper").animate({"left": -($(id).position().left)}, 600);

// remove "active" class from all links inside #nav
$('#nav a').removeClass('active');

// add active class to the current link
$(t).addClass('active');
}

使用新名称和新 div,示例函数 2。

它和这个在同一页上,当我复制并打印新脚本时,它们都不起作用,这很明显。

最佳答案

基于 Beneto 的评论:

function goto(id, t){   
$(".headbox-wrapper, .headbox-wrapper2").animate({"left": -($(id).position().left)}, 600);
$('#nav a').removeClass('active');
$(t).addClass('active');
}

HTML:

<div id='headbox-wrapper'>Click me!</div>
<div id='headbox-wrapper2'>Click me again!</div>

关于javascript - 使用新的 div 复制函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13551872/

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