1jQuery(function () { 2 3 jQuery( 'pre.code' ).each( function() { 4 5 var $elmt = jQuery( this ); 6 7 // Add button 8 //$btn = jQuery( '<div class="codeclipboard_button_container"><button></button></div>' ); 9 10 $btn = jQuery( '<div class="codeclipboard_button"></div>' ); 11 12 $elmt.prepend($btn); 13 14 // Setup click behaviour 15 $btn.click(function() { 16 var $txt = jQuery( '<textarea />' ); 17 $txt.val($elmt.text()).css({ width: "1px", height: "1px" }).appendTo('body'); 18 $txt.select(); 19 document.execCommand('copy'); 20 $txt.remove(); 21 }); 22 23 }); 24 25}); 26