Skip to content

Instantly share code, notes, and snippets.

@RakibSiddiquee
Created July 31, 2017 08:14
Show Gist options
  • Save RakibSiddiquee/cda966ed8031efe7d19bec0824452d30 to your computer and use it in GitHub Desktop.
Save RakibSiddiquee/cda966ed8031efe7d19bec0824452d30 to your computer and use it in GitHub Desktop.
Copy to clipboard by onclick
<!--Pass the url and id in input field-->
<input type="text" value="{{ config('app.url').config('appconfig.contentImagePath').$photo->img_path }}" id="url-{{ $photo->id }}" class="form-control" readonly>
<!--Pass the id in onclick button-->
<button type="button" onclick="copyUrl({{ $photo->id }})" class="btn btn-primary">Copy</button>
<!--The javascript code-->
<script>
function copyUrl(id){
//alert('hello');
document.getElementById('url-'+id).select();
//alert(d);
document.execCommand('copy');
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment