copy text to clipboard javascript
//As simple as this
navigator.clipboard.writeText("Hello World");
copy text to clipboard javascript
//As simple as this
navigator.clipboard.writeText("Hello World");
copy to cllipboard the html element
const copyWithStyle = ( element ) => {
const doc = document;
const text = doc.getElementById( element );
let range;
let selection;
if( doc.body.createTextRange ) {
range = doc.body.createTextRange();
range.moveToElement( text );
range.select();
} else if ( window.getSelection ) {
selection = window.getSelection();
range = doc.createRange();
range.selectNodeContents( text );
selection.removeAllRanges();
selection.addRange( range );
}
document.execCommand( 'copy' );
window.getSelection().removeAllRanges();
document.getElementById( 'clickMe' ).value = 'Copied to clipboard!';
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us