将对象附加到具有绝对位置的单击位置

Appending the object in the place of click with absolute position

本文关键字:位置 单击 对象      更新时间:2023-09-26

我想在单击的位置附加具有绝对位置的元素。我不知道如何测量顶部和左侧 css 属性器。

这是我的JS,它正在附加div编辑器。

$(document).on('dblclick', '.slide', function() {
   $(this).find(".step-wrapper").prepend('<div class="editor" contenteditable="true">  <h2  class="text2">Title</h2></div>'); 
});

HTML 结构:

<dic class="step">
  <div class="step-wrapper">
  </div>
</div>

像这样吗?

http://jsfiddle.net/pWqEQ/

.css({
        'left' : e.pageX,
        'top'  : e.pageY
    }