gpt4 book ai didi

javascript - div之间的导航和div的创建之间的一些问题

转载 作者:行者123 更新时间:2023-11-30 00:19:40 24 4
gpt4 key购买 nike

我有一个 div .content里面有两个 div(.content-1.content-2)。

里面的每个div .content只能有两个段落。

所以,如果所有 <div>已经有两个段落我想创建一个新段落来放置新添加的段落。

但是,我有两个问题:

-> <div> 之间导航之间的一些问题的和创造 <div>

-> 当我点击添加一个新段落和一个<div>已经有两段正在添加

我这里有一个工作示例:http://jsfiddle.net/t7o6emuf/2/

html:

<div id="container">
<div class="content">
<div class="content-1">
<a class="left" href="">Left</a>
<a class="right" href="">Right</a>
<p>P1</p>
<p>P2</p>
</div>
<div class="content-2">
<a class="left" href="">Left</a>
<a class="right" href="">Right</a>
<p>P3</p>
</div>
</div>
</div>

j查询:

$(document).ready(function() {
$(".left").click(function() {
$(this).parent().hide();
$(".content-" + getCurrIndex(this, true)).show();
return false;
});
$(".right").click(function() {
$(this).parent().hide();
$(".content-" + getCurrIndex(this, false)).show();
return false;
});
});

最佳答案

尝试在 return $(this).children("p").length !== 2;

处添加 "p"

jsfiddle http://jsfiddle.net/t7o6emuf/4/

关于javascript - div之间的导航和div的创建之间的一些问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33657747/

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