Q:

Copy to clipboard button does not work properly

I need some help regarding a copytoclipboard button. I can't seem to get it to work. Right now it copies the complete div, but i only want it to copy the text inside, including the breaks between paragraphs. I think I need to keep the paragraph  coding setup because I have buttons elsewhere that change the inner html. 
HTML and JS below.
Thanks a lot. Bart

function copyToClipboard(element) {
  var $temp = $("<textarea>");
  var brRegex = /<br\s*[\/]?>/gi;
  $("body").append($temp);
  $temp.val($(element).text().replace(brRegex, "\r\n")).select();
  document.execCommand("copy");
  $temp.remove();
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="report">

  <p style="font-size:125%" ;><b>Report: </b></p>
  <br>
  <p>Report 1.</p>
  <p id="1">entry 1: </p>
  <p id="2">entry 2: </p>
  <p id="3">entry 3: </p>
  <p id="4">entry 4: </p>
  <p id="5">entry 5: </p>
  <p id="6">entry 6: </p>
  <br>
  <p>Concluding: </p>
  <br><br>
  <p class="name"></p>
</div>

<div class="button01">
  <button type="button" onclick="copyToClipboard('div#report')">
      Copy div to clipboard
  </button>
</div>

So the easy answer was replacing .html with .text. I'm still very new to this. Thanks for the help.

A:

Try using $(element).text() instead of $(element).html()

function copyToClipboard(element) {
  var $temp = $("<textarea>");
  $("body").append($temp);
  $temp.val($(element).text() ).select();
  document.execCommand("copy");
  $temp.remove();
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="report">

  <p style="font-size:125%" ;><b>Report: </b></p>
  <br>
  <p>Report 1.</p>
  <p id="1">entry 1: </p>
  <p id="2">entry 2: </p>
  <p id="3">entry 3: </p>
  <p id="4">entry 4: </p>
  <p id="5">entry 5: </p>
  <p id="6">entry 6: </p>
  <br>
  <p>Concluding: </p>
  <br><br>
  <p class="name"></p>
</div>

<div class="button01">
  <button type="button" onclick="copyToClipboard('div#report')">
      Copy div to clipboard
  </button>
</div>

