JSFiddle - React, Tailwind, and code Playground
by rami7250
HTML
<textarea id="p1" name="select1" rows=3 cols=75 style="">
<a href="google.com">Google</a>
</textarea>
<!-- copy to clipboard-->
<button class="button-main" style="max-width:200px;" onclick="copyToClipboard('#p1')">Copy Text</button>
<script type="text/javascript">
function copyToClipboard(element) {
var $temp = $("<input>");
$("body").append($temp);
$temp.val($(element).text()).select();
document.execCommand("copy");
$temp.remove();
}
</script>
CSS
#p1 {
font-family:tahoma;
color:#555;border:1px dashed #ccc;
font-family:arial;
font-size:16px;
}
.button-main {
background-color: #fd9a0f;
background-repeat: repeat-x;
background-image: -moz-linear-gradient(top,#fee94f 0,#fd9a0f 100%);
background-image: -webkit-gradient(linear,left top,left bottom,color-stop(0%,#fee94f),color-stop(100%,#fd9a0f));
background-image: -webkit-linear-gradient(top,#fee94f 0,#fd9a0f 100%);
background-image: -ms-linear-gradient(top,#fee94f 0,#fd9a0f 100%);
background-image: -o-linear-gradient(top,#fee94f 0,#fd9a0f 100%);
background-image: linear-gradient(top,#fee94f 0,#fd9a0f 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fee94f',endColorstr='#fd9a0f',GradientType=0);
border: 1px solid #fa2;
height: 48px;
margin: 0;
-webkit-box-shadow: 0 1px 0 #000;
box-shadow: 0 1px 0 #000;
display: block;
padding: 0px 10px;
font-size: 25px;
font-weight: bold;
line-height: 40px;
cursor: pointer;
border-radius: 4px;
width: 100%;
vertical-align: middle;
color: #000;
}
.button-main:hover, .button-main:focus {
background-color: #fd9512;
background-repeat: repeat-x;
background-image: -moz-linear-gradient(top, #fedc4d 0, #fd9512 100%);
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #fedc4d), color-stop(100%, #fd9512));
background-image: -webkit-linear-gradient(top, #fedc4d 0, #fd9512 100%);
background-image: -ms-linear-gradient(top, #fedc4d 0, #fd9512 100%);
background-image: -o-linear-gradient(top, #fedc4d 0, #fd9512 100%);
background-image: linear-gradient(top, #fedc4d 0, #fd9512 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fedc4d', endColorstr='#fd9512', GradientType=0);
border-color: #ec8b11;
}
.button-main:active {
background-image:none;
border-color:#096eb3
}
JavaScript
var copytoclip=1
function HighlightAll(theField) {
var tempval=eval("document."+theField)
tempval.focus()
tempval.select()
if (document.all&©toclip==1){
therange=tempval.createTextRange()
therange.execCommand("Copy")
window.status="Contents highlighted and copied to clipboard!"
setTimeout("window.status=''",1800)
}
}