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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:44:43+00:00 2026-05-27T13:44:43+00:00

I have a few images with css -> $(.toolTip). <img width=150 height=200 src=<?php echo

  • 0
I have a few images with css -> $(".toolTip").

<img  width="150" height="200" src="<?php echo $avatarPath; ?> " class="toolTip" alt="<?php echo $control_panel_id ?>"/>

In my code, I want to refer to the image as a tag, and not to the class. I want to apply jquery methods, to the specific image that I hover over (taking into account that all those images have the same class name..)

Is there a way to do this … $(“.toolTip”). and then getSelector() method, so that I will get the specific element the mouse hovered over?!?

UPDATE:
but when I try to put mouseover, it doesnt work..it positions the div near the first picture…

 $('body').append('<div style="position:absolute; z-index:9999; background-color:#FF0000; width:150px; height:400px;" id="tooltip_outer"><div style="position:absolute; z-index:9999;" id="tooltip_inner"></div></div>');
 var $toolTip_inner=$("#tooltip_inner"); 
 var $toolTip_outer=$("#tooltip_outer");
// var $toolTip;



 if(!$(".toolTip"))
 {

     return;
 }


 $(".toolTip").hover(function(){

      $toolTip=$(this);
     if( $(this).attr("alt") )
     {  

        $tooltipText=$(this).attr("alt"); 

        $(this).attr("alt",'');

     }
     else
     {

       $bug[0]="There is no title a$toolTip_outerribute<br/>";
     }

      var t_width=$(this).outerWidth();
     var t_height=$(this).outerHeight();

    //Move css
     $toolTip_outer.css({
     'top':t_height-60,
     'left':t_width-140

    });

        $toolTip_inner.html("<p>The control panel id is: "+$tooltipText+" </p>");        
        $toolTip_outer.show();

    },  
  function(){
      //hide tooltip
    $toolTip_outer.hide();  
    //fix text
    $toolTip_inner.html(''); 

     if($toolTip_inner)
     {   // restore title text
        $(this).attr('alt',$tooltipText); 
     }

  })

The location takes into account the first image only..

  • 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-27T13:44:44+00:00Added an answer on May 27, 2026 at 1:44 pm
    $(".toolTip").hover(function(){
        // On mouseover
        // Here 'this' refers to the DOM Element that is hovered over
        // $(this) is a jQuery object containing it
    }, function(){
        // Here 'this' refers to the DOM Element that was hovered over
        // $(this) is a jQuery object containing it
    });
    

    If you use $(this) more than once in a function either use chaining, or store $(this) in a variable like var $this = $(this); and then use $this to speed up your script.

    Update

    First of all although this doesn’t solve your problem, but you should know that !$(".toolTip") is always false: http://jsfiddle.net/Jm7Kn/ You probably want !$(".toolTip").length which will only be false if there were no matches to the selector .toolTip.

    Your problem probably occurs around here:

    $toolTip_outer.css({
        'top':t_height-60,
        'left':t_width-140
    });
    

    Where you position the toolTip outer relative to it’s offset parent rather than relative to the tooltip you’re currently hovering over. You may have meant to use $ev_x to position close to the mouse cursor, or you may have wanted to use jQuery’s position function like $toolTip.position().top and $toolTip.position().left to get the position of the image that is being hovered over and put the tooltip near those co-ordinates. I’m not sure of your exact intentions though.

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

Sidebar

Related Questions

I have a few dynamically loaded images, with width and height being set inside
I have a number of images of very differing height and width that I
I'm using flex and have a few images that I need to sequence through.
I have a fair few images that I'm loading into a ListBox in my
I have to transform a few hundred images every day in a specific way.
I've seen a few fixes for allowing PNG images to have transparency in Internet
I have a few images on my site that will change over time. To
I have a div box (black) that will display a few different product images
I have tried a few different fixes using JQuery and CSS Tricks, but I
I've got a few HTML pages with the requisite images, css and other bits

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.