gpt4 book ai didi

jquery - 如何使用 jQuery 找出点击的 div 的编号(第 5 个、第 11 个、第 15 个等)?

转载 作者:行者123 更新时间:2023-12-01 02:44:26 25 4
gpt4 key购买 nike

假设我的 div 中有 10 张图像。如果我点击第 6 个,我怎样才能得到数字 6 的 int 值(或者图像的顺序是什么)?是否可以?我需要它使用 .get(currentindex+1) 导航到下一张图像

请不要建议我使用图库插件或其他任何东西,我需要按照自己的方式来做 ^^

一个有用的答案是 var currentindex = >something useful<

最佳答案

$("div img").on("click", function (e) {
console.log($(this).index());
});

http://api.jquery.com/index/

Demo.

关于jquery - 如何使用 jQuery 找出点击的 div 的编号(第 5 个、第 11 个、第 15 个等)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15434969/

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