Created
July 31, 2017 08:14
-
-
Save RakibSiddiquee/cda966ed8031efe7d19bec0824452d30 to your computer and use it in GitHub Desktop.
Copy to clipboard by onclick
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--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