$( document ).on( 'click', '.copy_registry_link', function(e) { e.preventDefault(); this.select(); this.setSelectionRange(0, 99999); /* For mobile devices */ /* Copy the text inside the text field */ navigator.clipboard.writeText(this.value); alert("Gift Registry link copied."); } );