Jquery – How to copy text to clipboard without flash example ?

Jquery – How to copy text to clipboard without flash example ?

In this post we will give you information about Jquery – How to copy text to clipboard without flash example ?. Hear we will give you detail about Jquery – How to copy text to clipboard without flash example ?And how to use it also give you demo for it if it is necessary.

We sometimes require to give function of copy some text by clicking on button or any link. There are several library can do copy text using flash player, but in this example i will do it without using flash player. In this example we will use

clipboard.js Jquery Plugin for copy to clipboard.

clipboard js provide us to simply copy to clipboard, you can simply do alert or message for after success coped. You can simply use by as written following code.

Code:

var clipboard = new Clipboard('.btn');


clipboard.on('success', function(e) {

e.clearSelection();

alert('Copy to Clipboard Successfully');

});


clipboard.on('error', function(e) {

alert('Something is wrong!');

});

Now i am going to share with you full example of clipboard js plugin. I use cdn for jquery and clipboard js that way you can run easily for testing. You can also see demo. So let’s see bellow example:

Example:

<!DOCTYPE html>

<html>

<head>

<title>Copy to clipboard JS Example</title>

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.js"></script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/1.5.16/clipboard.min.js"></script>

</head>

<body>


<!-- Target -->

<textarea id="bar" placeholder="Write Something for Copy"></textarea>


<!-- Trigger -->

<button data-clipboard-action="cut" data-clipboard-target="#bar">

Cut to clipboard

</button>


<script type="text/javascript">

var clipboard = new Clipboard('.btn');


clipboard.on('success', function(e) {

e.clearSelection();

alert('Copy to Clipboard Successfully');

});


clipboard.on('error', function(e) {

alert('Something is wrong!');

});

</script>


</body>

</html>

For more information you can get from here : clipboard.js

I hope it can help you….

Hope this code and post will helped you for implement Jquery – How to copy text to clipboard without flash example ?. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

Leave a Comment

Your email address will not be published. Required fields are marked *

84  +    =  90

We accept paid advance and paid guest Posting on our Site : Contact US