Solved

How do i get a popupBox on mouse over?

Posted on 2013-11-22
10
247 Views
Last Modified: 2013-11-25
below is my code.  I don't know why it will not work.  Any help would be appreciated.

Script tag in header:
<script type="text/javascript">
    $("a").hover(function(e) {
    $($(this).data("tooltip")).css({
        left: e.pageX + 1,
        top: e.pageY + 1
    }).stop().show(100);
}, function() {
    $($(this).data("tooltip")).hide();
});
    </script> 

Open in new window

CSS in header:
<style type="text/css">
        div {
    position: absolute;
    display: none;
    background: #ccc;
    border: 1px solid;
}
    </style>

Open in new window

Html in the body:
<a href="http://foo.com" data-tooltip="#foo">foo</a>
<br><br>
<a href="http://bar.com" data-tooltip="#bar">bar</a>

<div id="foo">foo means foo</div>
<div id="bar">bar means bar</div>

Open in new window

0
Comment
Question by:bmanmike39
  • 5
  • 5
10 Comments
 
LVL 58

Expert Comment

by:Gary
ID: 39670505
Code works fine as is
http://jsfiddle.net/GaryC123/64UUp/

Are you including the jQuery library in the page?
Have you got a live link?
0
 

Author Comment

by:bmanmike39
ID: 39670511
This is what i have in the head:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>

Open in new window

0
 
LVL 58

Expert Comment

by:Gary
ID: 39670529
Change your script to this and see if it works.

<script type="text/javascript">
$(function() {
    $("a").hover(function(e) {
    $($(this).data("tooltip")).css({
        left: e.pageX + 1,
        top: e.pageY + 1
    }).stop().show(100);
}, function() {
    $($(this).data("tooltip")).hide();
});
});
    </script>  

Open in new window

0
 

Author Comment

by:bmanmike39
ID: 39670546
Thanks! This works, except when the page loads the info show for both before I mouses over then the disappear and work
0
 
LVL 58

Expert Comment

by:Gary
ID: 39670558
Add this to your CSS
[data-tooltip*="#"] {
    display:none
}

Open in new window

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:bmanmike39
ID: 39670570
now nothing shows on page at all:

my CSS code:
<style type="text/css">
   div {
    position: absolute;
    display: none;
    background: #ccc;
    border: 1px solid;
    }
    [data-tooltip*="#"] {
    display:none
}

    </style>

Open in new window

0
 
LVL 58

Expert Comment

by:Gary
ID: 39670582
I'm wrong remove that.

This is your code exactly as you should have it with my amendments - can you see anything different since the tooltips only show on mouseover.
http://jsfiddle.net/GaryC123/4bFDT/
0
 

Author Comment

by:bmanmike39
ID: 39670596
It's exactly as it shows but i had 2 samples one in html and one in asp.net.  the html works.

Thanks!
0
 
LVL 58

Accepted Solution

by:
Gary earned 500 total points
ID: 39670598
So all good?
0
 

Author Closing Comment

by:bmanmike39
ID: 39676051
Thanks!!!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now