?
Solved

jquery list item left

Posted on 2011-09-30
7
Medium Priority
?
263 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
Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

 

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

WordPress Tutorial 4: Recommended Plugins

Now that you have WordPress installed, understand the interface, and know how to install new parts, let’s take a look at our recommended plugins.

Question has a verified solution.

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

This article discusses four methods for overlaying images in a container on a web page
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

777 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