Question: HTML

```
<div id="myContent">
    <div class="innerContent">Hello, this</div>
    <div class="innerContent">is a Test!</div>
    <div class="innerContent">Is it working?</div>
</div>

<div id="addContent">
</div>

```

JQuery

```
jQuery(document).ready(function(){
    var myContent = $('#myContent').text();
    $('#addContent').html(myContent);
});

```

What i want is that the contents of the div addContent look like this:

```
Hello, this
is a Test!
Is it working?

```

but the contents look like this

```
Hello, this is a Test! Is it working?

```

The problem is that the .text() method does not make Line-Breaks. How can i get the result with linebreaks? Important is that i can not change the original HTML-Code. How can i slip in Line-Breaks into the .text() -Method?

**Important**

I do not want to copy the HTML!!! It should be pure text without HTML-Elements! So please dont refer me to .html(). It should be line-breaks using \n.

Thanks

Answer: 
**Solution 1: cycle on the children element (as the div introduces the linebreak)**

```js
$(document).ready(function(){
    var myContent = $('#myContent').children().each(function(){
      $('#addContent').append($(this).text()).append('<br>');
    });
});
```

```html
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="myContent">
    <div class="innerContent">Hello, this</div>
    <div class="innerContent">is a Test!</div>
    <div class="innerContent">Is it working?</div>
</div>

<div id="addContent">
</div>
```

**Solution 2: String manipulation**

```js
$("#myContent")
  .text()
  .split('\n')
  .map((el) => el.trim())
  .filter((el) => !!el)
  .forEach((el) => $("#addContent").append(el+'<br>'))
```

```html
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="myContent">
    <div class="innerContent">Hello, this</div>
    <div class="innerContent">is a Test!</div>
    <div class="innerContent">Is it working?</div>
</div>

<div id="addContent">
</div>
```
You can save iterate the text of each inner div and add break.

```js
jQuery(document).ready(function(){
    var myContent = '';
    $("#myContent .innerContent").each(function(){
       myContent += $(this).text() +  ' <br> ' ;
       //console.log(myContent);
    });
    $('#addContent').html(myContent);
});
```

```html
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="myContent">
    <div class="innerContent">Hello, this</div>
    <div class="innerContent">is a Test!</div>
    <div class="innerContent">Is it working?</div>
</div>

<div id="addContent">
</div>
```