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 9136655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:58:52+00:00 2026-06-17T08:58:52+00:00

I was working on a tooltip from scratch. The code for the tooltip has

  • 0

I was working on a tooltip from scratch. The code for the tooltip has been added below.

Issue with following code:

The tooltip fades in and out on focussing or blurring on the text-area but the problem is, all the tooltips (tooltips corresponding to all the elements) fade in and out simultaneously.

The second issue is that the value of the text-area is same in all the tooltips which is the value of the first text-area.

PHP

<?php for($j; $j<5; $j++) { ?>
<tr>
<td style="position:relative"><?php echo CHtml::activeTextArea($PackageDeal,"package[$j][1]") ; ?>
    <div style="color:#0D776e;font-size:15px;font-family:calibri;padding:1%;margin:0 0.5%;;word-wrap:break-word;display:none;z-index:100;width:200px;mion-height:25px;position:absolute;top:30px;"></div>
</td>
</tr> 
<?php }?>

Jquery

<script src="jquery-1.8.3.min.js"></script>
<script>$(document).ready(function(){
        $("textarea").focus(function(){
            $("td div").fadeIn(400).css({"background-color":"#E7F1F0","border":"1px solid #86BBB6"});
            $("td div").html($("textarea").val());
        });
        $("textarea").blur(function(){
            $("td div").fadeOut(400).css({"background-color":"#E7F1F0","border":"1px solid #86BBB6"});

        });
        $("textarea").keyup(function(){
            $("td div").html($("textarea").val());
            });
            });
</script>

The issue is that I’m using this tooltip in a PHP for loop and I tried variety of ways so that the tooltip is functional. I need to ask whether I should keep an Id / Class for the tooltip (div element) and for the text-areas so that the text shown is different in all and all of them don’t show up simultaneously. Also I would like to know whether this is a jquery, php or html related issue. Thanks in Advance!

P.S. the tooltip works fine for single element.

  • 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-06-17T08:58:53+00:00Added an answer on June 17, 2026 at 8:58 am

    Because your page would have a lot of <td><div></div></td>s from generated HTML (by PHP), and all matches td div, all of them would show if you were to call $('td div').//so on

    So you need to specify which one you want to show, and in your case you want the one near to the element that is focused or blurred. jQuery is good at that.

    $("textarea").focus(function(){
        var targetArea = $(this);
        targetArea.siblings('div').fadeIn(400).css({"background-color":"#E7F1F0","border":"1px solid #86BBB6"})
            .html(targetArea.val());
    });
    

    Also, as per @joeltine answer, you also need to show only the html for that textarea too, so also use the same $(this) in your html call parameter.

    For performance, you may want to chain them together and cache $(this) to a variable as above too – the $ constructor is expensive.

    And one more thing, you seem to set css when it fades in and fades out, but they are not necessary – when you can set it in a css file instead. Their style can’t be seen if you set it beforehand and they are not shown (by display: none) anyway.

    $("textarea").focus(function(){
        var targetArea = $(this);
        targetArea.siblings('div').fadeIn(400).html(targetArea.val());
    });
    

    and in CSS:

    /* You really want to apply this css to all "td div" for this one! */
    td div {
       background-color: #E7F1F0;
       border: 1px solid #86BBB6;
       /* More styles for tooltips, such as display: none; position: relative; etc... */
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm porting working Clojure code (in a Leiningen project) from 1.2 to 1.3 and
Working on a carousel lightbox tooltip demo and as far I can see in
i was using tooltip and it is working perfectly, but it seems like my
I am working on a small app and am using jQuery Tools Tooltip (
I am working in WPF and I need to set the Text and ToolTip
Working with Reporting Services 2008 r2. So here's my issue: We have 5 reports
I have created the following custom tooltip with the custom template. <ToolTip x:Class=FireFly.Controls.CustomToolTip xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation
Working on a request to add a pretty tooltip to a page (using jQuery
I am using JQuery Tools plugin for tooltip its working fine but I would
I'm working on a site which uses the EZPZ tooltip jquery plugin, and 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.