gpt4 book ai didi

php - Jquery 切换 .. 固定对齐

转载 作者:太空宇宙 更新时间:2023-11-04 15:39:32 26 4
gpt4 key购买 nike

大家好,我有这个脚本

<a class="clickMe" toggle="first">Text 1</a>
</br>
<div id="first" class="text"> - This text will be toggled</div>

<a class="clickMe" toggle="second">Text 2</a>
</br>
<div id="second" class="text"> - This text will be toggled 2</div>

和 jquery

 $('a.clickMe').click(function () {
id = $(this).attr('toggle');
$('.text').not('#' + id).hide();
$('#' + id).show();
});

当我们点击 Text 1Text 2被点击,请查看demo

但现在我想做的是为切换文本设置固定位置/对齐方式,现在它在文本 1 或文本 2 下方切换,但我需要将其放在右侧,以便任何人单击 TEXT1 或 TEXT2 切换语句应显示在同一位置(右侧不在下方)...请帮助我解决此问题...

最佳答案

您可以使用非 block 元素,例如 spantoggle 方法。

<a class="clickMe">Text 1</a>
<span class="text"> - This text will be toggled</span>
<br/>
<a class="clickMe">Text 2</a>
<span class="text"> - This text will be toggled 2</span>

$('a.clickMe').click(function () {
$(this).next().toggle()
});

http://jsfiddle.net/LTYa2/66/

关于php - Jquery 切换 .. 固定对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12331377/

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