Copy a text of div by button click by javascript
Your html code <input type="button" id="copyme" value="COPY THE DIV"> <div id="mypolicy">THIS IS WHAT I WANT TO COPY</div> js script $('#copyme').on('click', function(){ id = this.id var range = document.createRange(); range.selectNode(document.getElementById(id)); window.getSelection().removeAllRanges(); // clear current selection window.getSelection().addRange(range); // to select text document.execCommand("copy"); });