Is there a way to get the value of a hidden div and clone the value to another div? I have a color picker in a ACF option page and am looking for a way show what that color would look like in another div.
To put it in another way if the value of a hidden input has #2b0059, it gets the value and copies it to another div.
My code so far:
jQuery(document).ready(function ($) {
$(document).on( "click", '#update', function() { $("#color1").clone().appendTo("#output .acf-input")
});
});
.acf-input {height:100px}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="color1">
<input type="hidden" name="acf[field_60d4d8ef09c78]" value="#2b0059">
</div>
<div id ="output">
<div class="acf-input"></div>
</div>
<button id="update">Update</button>
2
Answers
Looks like you don’t actually need to
clone
it, so how about just getting the value and adding a css background-color to the div ?Something like this:
It’s pretty simple you just need a proper selector.