Step 1 :-
First you need to check jQuery link in your XML file of your blogger website.
If you don't find you can add following script
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
Step 2 :-
Paste code in html view of your post where you want to show button.
Note:- In first line where "your Text" is written you need to type the text you need to copy.
<p id="p1">Your Text</p>
<button onclick="copyToClipboard('#p1')" style="border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
cursor: pointer;
background-color: #4CAF50;">Copy TEXT</button>
Step 3:-
Now you need paste the following code at the end of your post in html view.
<script>
function copyToClipboard(element) {
var $temp = $("<input>");
$("body").append($temp);
$temp.val($(element).text()).select();
document.execCommand("copy");
$temp.remove();
}
</script>
Note:- Remember if you are adding more than one copy text. then change if ID of the paragraph.
For example:-
<p id="p2">Your Text</p>
<button onclick="copyToClipboard('#p2')" style="border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
cursor: pointer;
background-color: #4CAF50;">Copy TEXT</button>
0 Comments
If you have any problem in code write in comments!