Solved

jquery list item left

Posted on 2011-09-30
7
246 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
Comment Utility
Do you have a live URL? Or rendered HTML/CSS/Javascript code?
0
 

Author Comment

by:jackjohnson44
Comment Utility
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
Comment Utility
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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

Author Comment

by:jackjohnson44
Comment Utility
I really just want to grab the UL, thanks.
0
 
LVL 30

Expert Comment

by:LZ1
Comment Utility
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
Comment Utility
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
Comment Utility
It is the answer.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

CSS is a visual language used to classify objects and define rules about how they should be displayed. CSS skills aren’t restricted to developers anymore, there is a big benefit to having a basic understanding of the language, regardless of your occ…
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 embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

762 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

12 Experts available now in Live!

Get 1:1 Help Now