javascript - Append div at cursor in a contenteditable div -
this question has answer here:
i have contenteditable div need append div(child) @ caret position?
i added text @ caret position using sample in stack. didn't find way append div @ caret position.
how it?
var appendtext = "<div class='ui-state-default' contenteditable='false'> <span>"+ui.draggable.text()+"</span> <span class='ebappendfieldclose'>x</span> </div>" $("#ebplaceholder").append(appendtext);
right use normal method (like this).
not sure you're trying do; placing div on cursor position?
var appendtext = "<div class='ui-state-default' contenteditable='false'><span>" + ui.draggable.text() + "</span><span class='ebappendfieldclose'>x</span></div>" //i'm using 'click', can whatever want $("#ebplaceholder").on('click', function(e) { appendtext.css({position: 'absolute', top: e.clienty + 'px', left: e.clientx + 'px' }); e.target.append(appendtext); });
Comments
Post a Comment