Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6232283
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:05:26+00:00 2026-05-24T10:05:26+00:00

I have a textContainer where there will some default text. And there are some

  • 0

I have a textContainer where there will some default text. And there are some clickable text(A,B,C). When a text is clicked it needs to show the text associated with it(pre define in another div) on the textContainer. I found some tutorial which uses next selector to grab the text but chances are that I will need to update text in several containers. So Try to create a function that will do the work and update text in multiple containers(divs) if needed. I hope it make sense(TGIF..)

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$(".content").css('display','none');
$(".handler").click(function(){ 
    alert("what what");
  });
 });
</script>

<body>
<div id="textContainer">
    <P>This is where the text is update</P>
</div>

<div class="handler A" >A</div>
<div class="handler B" >B</div>
<div class="handler C" >C</div>

<div class="content textA"> Text A </div>
<div  class="content textB"> Text B </div>
<div  class="content textC"> Text C </div>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T10:05:26+00:00Added an answer on May 24, 2026 at 10:05 am

    I’d personally recommend using data- attributes rather than class names to help you identify which handler is tied to which content:

    <div id="textContainer">
        <P>This is where the text is update</P>
    </div>
    <div class="handler" data-handles="A">A</div>
    <div class="content" data-text="A"> Text A </div>
    ...
    
    <script type="text/javascript">
        $(document).ready(function() {
    $(".content").css('display','none');
    $(".handler").click(function(){ 
        var identifier = $(this).attr('data-handles');
        var content = $(".content[data-text=" + identifier + "]").html();
        $("#textContainer > p").html(content);
      });
     });
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have I understod the following right? font-family:sans-serif; Above will result in the default sans-serif
Have you ever seen any of there error messages? -- SQL Server 2000 Could
Trying to change the selected text background color for an NSTextField (we have a
Have a look at the following code (additionally, you will need jquery.js , jquery.viewport.js
I have added text animation using javascript function: <div id=stats> <div class=textEffects> Text 1
I have some unit tests that run fine on my dev machine on both
I have a page with the following structure: 1. Text 2. Form with SUBMIT
Have just started using Google Chrome , and noticed in parts of our site,
Have you guys had any experiences (positive or negative) by placing your source code/solution
Have just started using Visual Studio Professional's built-in unit testing features, which as I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.