Set Div position to Mouse position with jQuery

前端 未结 3 859
南方客
南方客 2021-01-04 10:06

I am trying to position my Div wherever the user clicks on my Image.

test is my Div, and myimg is my image.

Here is my JS:<

3条回答
  •  借酒劲吻你
    2021-01-04 10:59

    I think you probably want

    $("#test").css({position:"absolute", left:e.pageX,top:e.pageY});
    

    instead of

    $("#test").offset({left:e.pageX,top:e.pageY});
    

提交回复
热议问题