Solved

jquery list item left

Posted on 2011-09-30
7
248 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

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.
Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

786 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