开发者

simply tooltip div - top position and hide

开发者 https://www.devze.com 2023-03-15 02:35 出处:网络
I would like help with http://jsfiddle.net/VmXU9/34/ . $(\".click\").click(function() { var s = $(this).offset();

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 开发者_StackOverflow社区can I approach this?


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();
        }
   });
});
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号