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

  • Home
  • SEARCH
  • 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 9247113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:39:06+00:00 2026-06-18T09:39:06+00:00

I have the following markup that I am applying the succedding Javascript to in

  • 0

I have the following markup that I am applying the succedding Javascript to in order to produce a tooltip, the problem is I am trying to set the contents of the tooltip to the contents of the span.

I cannot figure out a way of doing this without 500 different document.get etc…

Basically I want to know: In the showTooltip function, how can I get the contents of the span dynamically?

Markup:

<ul class="exec-List">
                    <li>
                        <img src="file:///C|/Users/tsujp/Documents/Everything/Adobe Projects/DW/KCC/Website/V8/src/committee/mirae.png" /> 

                        <span class="tooltip-span">Conten2t</span>

                    </li>
                    <li>
                        <img src="file:///C|/Users/tsujp/Documents/Everything/Adobe Projects/DW/KCC/Website/V8/src/committee/mirae.png" /> 

                        <span class="tooltip-span">Content55</span>

                    </li>
                </ul>

Javascript:

$(document).ready(function() {

var changeTooltipPosition = function(event)
{
  var tooltipX = event.pageX - 8;
  var tooltipY = event.pageY + 8;
  $('div.tooltip').css({top: tooltipY, left: tooltipX});
};

function showTooltip(event/*, index, el*/)
{
    /*alert( $(this).parent(this).get(0).tagName );*/

    $('div.tooltip').remove();
    $('<div class="tooltip">/* + tooltip_text +*/ </div>')
        .appendTo('body');
    changeTooltipPosition(event);
};

var hideTooltip = function()
{
   $('div.tooltip').remove();
};

$('span').each(function()
{
    if( $(this).hasClass( 'tooltip-span' ) )
    {                       
        //tooltip_text = $(el).html();

        $(this).parent(this).bind(
        {           
            mousemove : changeTooltipPosition,
            mouseenter : showTooltip/*( HOW DO I PASS 'EVENT' HERE)*/,
            mouseleave: hideTooltip
        });
    }
});

});

  • 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-18T09:39:07+00:00Added an answer on June 18, 2026 at 9:39 am

    You can select on $('.tooltip-span', this) and take the text()

    function showTooltip(event/*, index, el*/)
    {
        var text = $('.tooltip-span', this).text();
        /*alert( $(this).parent(this).get(0).tagName );*/
    
        $('div.tooltip').remove();
        $('<div class="tooltip">' + text + '</div>')
            .appendTo('body');
        changeTooltipPosition(event);
    };
    

    JSFiddle

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following markup that is used to produce a pop-up style mega-menu
I have the following markup that I need to put the value of the
I have the following markup <ol> <li class=ListItem> <span class=sub>@qItem.CategoryText</span> <input type=image src=http://icons.iconarchive.com/icons/tatice/just-bins/256/bin-red-full-icon.png width=30
I have the following markup <span id=add> <li style=float: left;margin-right: 10px;> <b class=bg>Nom</b><br />
I'm trying to teach myself CSS and have the following markup: <style type=text/css> #content
I have the following markup; <div class=model-timeline> <p>Text</p> <div class=timeline> <div class=span-blank-5></div> <div class=time-span-1></div>
I have the following markup: <button class=button type=button><span>Edit</span></button> I want to have a click
I have the following HTML markup: <div class=votes meta engagement> <span class=vote-count> <span class=vote-total>
I have the following markup (and the resulting display shown below that). I want
I have the following markup: <div id=selectable1> <span class=drag>Some Text</span> <span class=drag>Some Text</span> <span

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.