1const copyWithStyle = ( element ) => {
2
3 const doc = document;
4 const text = doc.getElementById( element );
5 let range;
6 let selection;
7
8 if( doc.body.createTextRange ) {
9
10 range = doc.body.createTextRange();
11 range.moveToElement( text );
12 range.select();
13
14 } else if ( window.getSelection ) {
15
16 selection = window.getSelection();
17
18 range = doc.createRange();
19 range.selectNodeContents( text );
20
21 selection.removeAllRanges();
22 selection.addRange( range );
23
24 }
25
26 document.execCommand( 'copy' );
27 window.getSelection().removeAllRanges();
28 document.getElementById( 'clickMe' ).value = 'Copied to clipboard!';
29
30}