Copy Text with jquery

Copy text with jquery and element text also

by Khadeer Mohammed

HTML

<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>

<div id="all">
<p id="p1">May 14, 2016 - How to copy text to clipboard with Javascript easily ... exists :3") } existsTextarea.value lkjhfkjdhd </p>
<p id="p2">Hi, I'm the 2nd TEXT</p><br/>

<button onclick="copyText('#p1')" type="button">Copy TEXT 1</button>
<button onclick="copyText('#p2')" type="button">Copy TEXT 2</button>

  
<br/><br/><input class="textBox" type="text" id="" placeholder="Dont belive me?..TEST it here..;)" />
</div><br/>


<button onclick="copyText('#all')" type="button">Copy All Data</button>

<script>
	function copyText(element) {
	
  var $temp = $("<input>");
  $("body").append($temp);
  $temp.val($(element).html())
  $temp.select();
  document.execCommand("copy");
  $temp.remove();
  //alert();
}
</script>