Solved

jquery list item left

Posted on 2011-09-30
7
247 Views
Last Modified: 2012-05-12
I am writing somethign to put a tool tip next to the li when you mouse over.  It works, but it gives me the x offset of theof the li text, not the full menu.  The UL is styled so it a border is behind it, making a side navigation bar. I want the popup to appear to the left of the entire menu, not the left of the word that I am hovering.

meaning:
short
very long text

If I mouse over short, I want it to the left of the whole menu since it looks like a solid box.
0
Comment
Question by:jackjohnson44
  • 4
  • 3
7 Comments
 
LVL 30

Expert Comment

by:LZ1
ID: 36892509
Do you have a live URL? Or rendered HTML/CSS/Javascript code?
0
 

Author Comment

by:jackjohnson44
ID: 36892643
I have a li with the class left-nav-item.

This will display a popup next to the li.
I really need the ul that contains the li.
If I try to access it using parent, it won't work and will throw an error "this.parent is not a function"
/*tool tip*/
this.myhover = function () {
    this.xOffset = -10; // x distance from mouse
    this.yOffset = 10; // y distance from mouse       

    $(".left-nav-item").unbind().hover(
        function (e) {
            this.top = (e.pageY + yOffset);
            this.left = (e.pageX + xOffset);

            //this.parent().css('background-color', 'red');

            $('body').append('<p id="new">My Hover Text</p>');
            $('p#new').css("top", this.top + "px").css("left", this.left + "px").css("position", "absolute").fadeIn("slow");
        },
        function () {
            //$("p#new").fadeOut("slow").remove();
        }
    ).mousemove(
        function (e) {
            this.top = (e.pageY + yOffset);
            this.left = (e.pageX + xOffset);
            //$("p#new").css("top", this.top + "px").css("left", this.left + "px");
        }
    );

};

jQuery(document).ready(function ($) { myhover(); });

Open in new window

0
 
LVL 30

Expert Comment

by:LZ1
ID: 36892668
And you wrote this function yourself? Why not use a pre-existing plugin?  

http://flowplayer.org/tools/tooltip/index.html
http://code.drewwilson.com/entry/tiptip-jquery-plugin 

Just wondering...
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:jackjohnson44
ID: 36892680
I really just want to grab the UL, thanks.
0
 
LVL 30

Expert Comment

by:LZ1
ID: 36893145
What do you mean by:
>>I really just want to grab the UL, thanks.

You didn't seem to answer any of my questions.
0
 

Accepted Solution

by:
jackjohnson44 earned 0 total points
ID: 36903596
I don't have a live url, and this was from a pre-existing plugin.  The pre-existing didn't make the hover to the right of the ul, just the li, which brings me to this question.

The answer:
To get a reference to a ul from the hover of a li
$(this).parent()

I was using
this.parent()

Thanks
0
 

Author Closing Comment

by:jackjohnson44
ID: 36935166
It is the answer.
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

This article discusses how to create an extensible mechanism for linked drop downs.
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
In this tutorial viewers will learn how to style rounded corners for elements in CSS using the border-radius property Begin with a normal styled element such as a div: To style all four corners of the div to be the same degree of roundness, use the …

914 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

18 Experts available now in Live!

Get 1:1 Help Now