Basically I have to copy content of a div to a textarea, have the ability to edit it inside the textarea and the changes should be saved inside the initial div.
I need to prevent an attribute which looks like data-bind: "some stuff;"
and can be set for the children of the initial wrapper div and the comments from being shown inside the textarea.
Here's what I have so far, sadly without any clue how to exclude text when getting the html. https://jsfiddle.net/2kduy9vp/112/
$('.editor').html($('.main').html());
$('.editor').on('input propertychange', function(){
$('.main').html($(this).val());
});
.editor {
width: 100%;
height: 500px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="main">
<!-- I'm a comment, don't copy me -->
<div class="child" data-bind="don't copy me" style="background-color: gray; width: 250px;">
<span> I'm gray, copy me</span>
</div>
<!-- I'm a comment, don't copy me -->
<div class="child" data-bind="don't copy me" style="background-color: pink; width: 250px;">
<span> I'm pink, copy me</span>
</div>
</div>
<textarea class="editor"></textarea>