E
E
Egor Trubnikov-Panov2014-06-02 14:17:09
JavaScript
Egor Trubnikov-Panov, 2014-06-02 14:17:09

How to cure a tooltip?

Filed the Tooltip, made it in the form of a div, which is inserted below the body.

When hovering over an element that has a tooltip attached to it. This div is positioned relative to this element, right up against its borders.
There was such a problem: it is necessary to be able to interact with the contents of the tooltip itself,
i.e. when the cursor leaves the element, but is on the tooltip. The tooltip itself should not be hidden.

Did it like this:

$obj.bind("mouseenter focus", fn.open);
$obj.bind("focusout mouseout", fn.close);

  fn.close = function (e) {
            if (Boolean($(".tooltip:hover").length)) {
                $tooltip.on("mouseout", function () {
                    !Boolean($(".tooltip:hover").length) && $(this).off("mouseout").hide()
                })
            } else {
                $tooltip.hide();
            }
        };


It works in chrome but doesn't work in FF and ie.
When you hang a tooltip on links, when you move the cursor over them, the tooltip starts blinking.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ilya Lesnykh, 2014-06-02
@Aliance

Boolean($(".tooltip:hover").length

why write like that? write like this:
$(selector).size()

N
Nikolai Vasilchuk, 2014-06-02
@Anonym

$obj.bind("mouseenter focus", fn.open);
$obj.bind("focusout mouseleave", fn.close);

  fn.close = function (e) {
            if ($tooltip.is(':hover')) {
                $tooltip.on("mouseleave", function () {
                    !$tooltip.is(':hover') && $tooltip.off("mouseleave").hide();
                })
            } else {
                $tooltip.hide();
            }
        };

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question