gpt4 book ai didi

javascript - 替换相同的类 div 并且没有 ID

转载 作者:太空宇宙 更新时间:2023-11-03 20:42:16 25 4
gpt4 key购买 nike

enter image description here

我有四个 DIVS,一个准备好了,另外三个还隐藏着。当按下指向第二个 div 的链接时,我希望显示第二个 div,下一个链接也是如此。

问题是,所有四个 DIV 没有 ID 并且具有相同的类。

我只是希望它在不知道 div 的 ID 和类或 div 中的任何内容的情况下自动运行。它可能看起来像幻灯片,但具有点击功能。

<p> link to the ready div </P> 
<p> link to the second div </P>
<p> link to the third div </P>
<p> link to the last div </P>


<div id="wrapper">

<div> this is the div that is ready. This div has no ID and has the same class with others <div>

<div> this is the second div that is hidden. This div has no ID and has the same class with others <div>

<div> this is the third div that is hidden. This div has no ID and has the same class with others <div>

<div> this is the last div that is hidden. This div has no ID and has the same class with others <div>

</div>

FIDDLE

最佳答案

我制作了一个可能适合您的情况的 fiddle ,请看一下。您可以根据需要进行一些修改。

var currentDiv = 0;
$(document).ready(function(){
$(".container div").click(function(){
$(".container div").eq(currentDiv+1).css( "display", "block" );
currentDiv++;
})
});

JSFIddle Link

关于javascript - 替换相同的类 div 并且没有 ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24730833/

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