Gisinior
Gisinior

Reputation: 23

simply tooltip div - top position and hide

I would like help with http://jsfiddle.net/VmXU9/34/ .

$(".click").click(function() {
    var s = $(this).offset();
    left = s.left + $(this).width();
    $("#THREE").css({
        'opacity': 0.80
    });


    $("#THREE").css(s);
    $("#THREE").css({
        left: left
    });

});

I would like to modify the top and left positions of the yellow <div> to, for example, left: 10px, top: -20px. I would also like it to hide if I click outside it. How can I approach this?

Upvotes: 0

Views: 309

Answers (1)

Bj&#246;rn
Bj&#246;rn

Reputation: 2648

You could use something like:

$(function() {
   $(document).click(function(e)    {
        var $div = $("#yourDiv");

        // if the click was outside the div, hide it
        if(e.target != $div.get(0)) {
            $div.hide();
        }
   });
});

Upvotes: 1

Related Questions