contenteditable shows markup at the result

55 views Asked by At

I'm using contenteditable as text input and I want to show (on a different div) the text input when the user click on 'Submit'.

Let's say the user types:

hello
hello

and I check

$('.answer_comments_editable').html();

then I get "hello<div>hello</div>".

I don't want to show any html markup on my final display, so how can I avoid this and instead show the clean text?

1

There are 1 answers

2
Brian H On

try the textContent property

var contenteditable = document.querySelector('.answer_comments_editable'),
    text = contenteditable.textContent;