Skip to content

Instantly share code, notes, and snippets.

@kreamweb
Created June 30, 2017 13:08
Show Gist options
  • Select an option

  • Save kreamweb/8c36b52c75147b98aaea3c6f39424909 to your computer and use it in GitHub Desktop.

Select an option

Save kreamweb/8c36b52c75147b98aaea3c6f39424909 to your computer and use it in GitHub Desktop.
copy text in the clipboard
$( document ).on( 'click', '.yith-wcbk-copy-to-clipboard', function ( event ) {
var target = $( this ),
selector_to_copy = target.data( 'selector-to-copy' ),
obj_to_copy = $( selector_to_copy );
if ( obj_to_copy.length > 0 ) {
var temp = $( "<input>" );
$( 'body' ).append( temp );
temp.val( obj_to_copy.html() ).select();
document.execCommand( "copy" );
temp.remove();
}
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment