gpt4 book ai didi

javascript - 如何循环动态生成的id?

转载 作者:行者123 更新时间:2023-11-30 10:13:04 24 4
gpt4 key购买 nike

<分区>

        /**Script**/ 
function AnimateFish() {
var Fish3 = $("#fish1").not(".HoverFish"),
theContainer = $("#container"),
maxLeft = theContainer.width() - Fish3.width() - 50,
maxTop = theContainer.height() - Fish3.height(),
leftPos = Math.floor(Math.random() * maxLeft),
topPos = Math.floor(Math.random() * maxTop) + 100,
imgRight = "Assets/fish-glow3-right.gif",
imgLeft = "Assets/fish-glow3.gif";


if (Fish3.position().left <= leftPos) {
$(this).css("background-image", 'url("' + imgRight + '")');
} else {
$(this).css("background-image", 'url("' + imgLeft + '")');
}

Fish3.animate({
"left": leftPos,
"top": topPos
}, 1800, AnimateFish);
}
AnimateFish();

您好,ID“#fish1”将动态生成,如#fish1、#fish2 #fish3 ...实际上我希望为所有生成的 ID 运行此函数,请给我解决方案和一个主要问题鱼正在为这段代码反转我试过很多PLZ你能帮我吗...

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