一个跟随鼠标移动的DIV

来源:互联网 发布:简谱视唱教学软件 编辑:程序博客网 时间:2024/05/02 00:04
 

 $(".personList td img").each(function () {
                var xOffset = 0;
                var yOffset = 0;
                var $this = $(this);
                var eid = $this.next().attr("alt");
                $this.hover(
                    function (e) {
                        var str=getPersonnel(eid);
                       
                        $("#boxM").css(
                        {
                            "top": (e.pageY - xOffset) + "px",
                            "left": (e.pageX + yOffset) + "px"
                        }
                        ).fadeIn("slow"); ;
                    },

                    function () {
                        $("#boxM").fadeOut("slow");
                    }

                );

            });
        });

 function getPersonnel(eid) {
       $.post("/Ashx/AsynLoad.ashx", { "Action": "LoadPersonnel", "eid": eid },
        function (data) {
        $("body").append("<div id='boxM'>" + data + "</div>");
});