gpt4 book ai didi

javascript - fadeToggle div 然后再返回

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:42:28 26 4
gpt4 key购买 nike

抱歉,如果这是一个非常明显的问题需要解决。 What I am trying to do is have a div, when selected is replaced with another div with the option to revert "back"to the old div when "back"is clicked.

这是我目前所拥有的:

$(document).ready(
function() {
$("#display-one").click(function() {
$("#display-two").fadeToggle();
$("#display-one").fadeToggle();
});
});
#display-two {
display: none;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script>
<div id="header">
<div id="display-one"><a href="#">Dispay One</a></div>
</div>

<div id="display-two">
<p><a href="#">Display Two</a></p>
<h3>
<div id="back">
<a href="#">back</a>
</div>
</h3>
</div>

这是一个 JSFiddle:https://jsfiddle.net/uL8z87r7/1/

在此先感谢您的帮助和提示!-约翰

最佳答案

只需将 #back a 添加到您的选择器,这样它就会是 $("#display-one, #back a")

$("#display-one, #back a").click(function() {
$("#display-two").fadeToggle();
$("#display-one").fadeToggle();
});
#display-two {
display: none;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="header">
<div id="display-one"><a href="#">Dispay One</a>
</div>
</div>

<div id="display-two">
<p><a href="#">Display Two</a>
</p>
<h3>
<div id="back">
<a href="#">back</a>
</div>
</h3>
</div>

关于javascript - fadeToggle div 然后再返回,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37389769/

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