大家好,我有这个脚本
<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 1
或 Text 2
被点击,请查看demo
但现在我想做的是为切换文本设置固定位置/对齐方式,现在它在文本 1 或文本 2 下方切换,但我需要将其放在右侧,以便任何人单击 TEXT1 或 TEXT2 切换语句应显示在同一位置(右侧不在下方)...请帮助我解决此问题...
最佳答案
您可以使用非 block 元素,例如 span
和 toggle
方法。
<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()
});
关于php - Jquery 切换 .. 固定对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12331377/