Solved

jquery list item left

Posted on 2011-09-30
7
253 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
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…
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…

739 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