Jquery toggle .. fixing alighnment

Hello people i have this script

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

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

and the jquery

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

above code works fine by toggling This text will be toggled or This text will be toggled 2 when we click on Text 1 or Text 2 is clicked, please check the demo

but now what i trying to do is to have fixed position/alignment for the toggled text,right now it is toggled below Text 1 or Text 2 ,BUT I NEED TO PUT THIS ON RIGHT HAND SIDE SO THAT WHEN EVER ANYONE OF THE TEXT1 OR TEXT2 IS CLICKED TOGGLED STATEMENT SHOULD BE SHOWN ON THE SAME PLACE(RIGHT SIDE NOT BELOW) ...PLEASE HELP ME TO FIX THIS....


Why not try this by using jQuery's .text() feature:


You can use a non-block element like span and toggle method.

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

$('a.clickMe').click(function () {


You could try this:

div {
    display: inline-block;

Here is the corrected working Live Demo.

Need Your Help

How to get HTML element coordinates using C#?

c# offset ihtmldocument2

This is related to (http://stackoverflow.com/questions/1547614/how-to-get-html-element-coordinates-using-c)

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.