function copyElementContent(element){ var selection = window.getSelection(); var range = document.createRange(); range.selectNodeContents(element); selection.addRange(range); document.execCommand('copy'); selection.removeAllRanges(); }