I'm trying to make an app where the user can change the bg color of a button and after that copy the CSS code from the <style>
tags with changed background color into the buffer. For the color picker, I use http://jscolor.com/. I think I need to assign a variable with the color to the background property like this: background: <?php echo $valueInput; ?>;
but I can't find the value where it's stored and doesn't know how to pass it to the variable. My code does copy the CSS but instead of some background color there is just this: .jscolor{valueElement:'valueInput'}
.
<script>
function copyToClipboard(element) {
var $temp = $("<input>");
$("body").append($temp);
$temp.val($(element).text()).select();
document.execCommand("copy");
$temp.remove();
}
</script>
<button class="jscolor{valueElement:'valueInput', styleElement:'button_cont'}" >
Click here to pick a color
</button>
Value: <input id="valueInput" value="ed3330">
<?php $valueInput = ".jscolor{valueElement:'valueInput'}"; ?>
<style type="text/css">
#button_cont {
color: #fff !important;
text-transform: uppercase;
text-decoration: none;
background: <?php echo $valueInput; ?>;
padding: 10px;
border-radius: 5px;
display: inline-block;
border: none;
transition: all 0.4s ease 0s;
margin-left: 10px;
}
#button_cont:hover {
background: #434343;
letter-spacing: 1px;
-webkit-box-shadow: 0px 5px 40px -10px rgba(0,0,0,0.57);
-moz-box-shadow: 0px 5px 40px -10px rgba(0,0,0,0.57);
box-shadow: 5px 40px -10px rgba(0,0,0,0.57);
transition: all 0.4s ease 0s;
}
</style>
<div id="button_cont" >CALL TO ACTION</div>
<button onclick="copyToClipboard('style')">Copy CSS</button>
</div> ```