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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:36:20+00:00 2026-06-03T07:36:20+00:00

I have a function for creating a tooltip from a title. I am trying

  • 0

I have a function for creating a tooltip from a title. I am trying to wrap this function in an if statement that checks the title length before returning the tooltip. But it doesn’t seem to want to return anything. Is there a better way to do this then with an if statement?

$(document).ready(function() {

 if ($('#menu-headermenu a').attr('title').length == 0) {

 return null;

} else {

//Select all anchor tag with rel set to tooltip
$('#menu-headermenu a').mouseover(function(e) {

    //Grab the title attribute's value and assign it to a variable
    var tip = $(this).attr('title');    

    //Remove the title attribute's to avoid the native tooltip from the browser
    $(this).attr('title','');

    //Append the tooltip template and its value
    $(this).append('<div id="tooltip"><p>Take me to:<p><div class="tooltipcontent"' + tip + '</div></div>');     

    //Set the X and Y axis of the tooltip
    $('#tooltip').css('top', e.pageY + 10 );
    $('#tooltip').css('left', e.pageX + 20 );

    //Show the tooltip with faceIn effect
    $('#tooltip').fadeIn('500');
    $('#tooltip').fadeTo('10',0.8);

}).mousemove(function(e) {

    //Keep changing the X and Y axis for the tooltip, thus, the tooltip move along with the mouse
    $('#tooltip').css('top', e.pageY + 10 );
    $('#tooltip').css('left', e.pageX + 20 );

}).mouseout(function() {

    //Put back the title attribute's value
    $(this).attr('title',$('div.tooltipcontent').html());

    //Remove the appended tooltip template
    $(this).children('div#tooltip').remove();

});

}
});
  • 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-03T07:36:21+00:00Added an answer on June 3, 2026 at 7:36 am

    Have you considered using existing solutions? (e.g. http://jquery.bassistance.de/tooltip/demo/)

    As for your question, you can just add a filter to your selector: $('#menu-headermenu a[title]')

    This should make it so that only elements with a title attribute will have the events attached.

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

Sidebar

Related Questions

I haven't had any luck creating function that removes sublists. I have this list:
I currently have a function that looks like this: public void AnimateLayoutTransform(object ControlToAnimate) {
I'm creating a indicator applet using Python (pygtk) and I have a function that
I have the below function creating new panels inside my ViewStack.. This works fine
I am creating a generic function that have the function definition as: public static
I have a function in my login form that checks if the email and
So I have here a JavaScript stack built after this function: function Stack() //Creating
I want to make sure the option elements I'm creating in this function have
I'm creating a little dynamic tooltip function. Basically if I have a link like
I have a function that reads user input from std::cin, and I want to

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.