티스토리 뷰

노트/JS

contenteditable

태엽푸는새 2016. 8. 18. 19:43

$('body').on('focus', '[contenteditable]', function() {
    var $this = $(this);
    $this.data('before', $this.html());
    return $this;
}).on('blur', '[contenteditable]', function() {
    var $this = $(this);
    if ($this.data('before') !== $this.html()) {
        $this.data('before', $this.html());
        $this.trigger('change');
    }
    return $this;
});


$("div.div_memo").on("change", function() {
    alert($(this).html());
});

'노트 > JS' 카테고리의 다른 글

beep  (0) 2016.08.18
number_format  (0) 2016.08.18
refresh  (0) 2016.08.18
Convert a DOM element to a jQuery element  (0) 2016.08.18
쿠키  (0) 2016.08.17
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
TAG
more
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함