2

I make a jquery tooltip but have problem with it, when mouse enter on linke "ToolTip" box tooltip don't show in next to link "ToolTip" it show in above linke "ToolTip" , how can set it?

Demo: http://jsfiddle.net/uUwuD/1/

function setOffset(ele, e) {
    $(ele).prev().css({
        right: ($(window).width() - e.pageX) + 10,
        top: ($(window).height() - e.pageY),
        opacity: 1
    }).show();
}

function tool_tip() {
    $('.tool_tip .tooltip_hover').mouseenter(function (e) {
        setOffset(this, e);
    }).mousemove(function (e) {
        setOffset(this, e);
    }).mouseout(function () {
        $(this).prev().fadeOut();
    });
}
tool_tip();
2

2 Answers 2

1

Something like this works, you've still got a bug where the tooltip sometimes fades away on the hover of a new anchor. I'll leave you to fix that, or for another question.

function setOffset(ele, e) {
    var tooltip = $(ele).prev();
    var element = $(ele);
    tooltip.css({
        left: element.offset().left - element.width() - tooltip.width(),
        top: element.offset().top - tooltip.height(),
        opacity: 1
    }).show();
}

And here's the jsFiddle for it: http://jsfiddle.net/uUwuD/4/

Sign up to request clarification or add additional context in comments.

Comments

0

you need to calculate the window width and minus it with the width of your tooltip and offset

 if(winwidth - (offset *2) >= tooltipwidth  + e.pageX){
                            leftpos = e.pageX+offset;
                    } else{
                        leftpos = winwidth-tooltipwidth-offset;
                    }

if you want more detail please refer :)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.