I have this HMTL structure
.list, .list ul{
list-style-type: none;
}
<ul class="list">
<li class="radioSettings">
<ul>
<li>
<span>
<input type="radio" value="white">
</span>
</li>
<li>
<span>
<input type="radio" value="dark">
</span>
</li>
</ul>
</li>
<li id="colors_body">
<input type="text" value="ffffff" class="color">
</li>
<li id="colors_wrapper">
<input type="text" value="000000" class="color">
</li>
<li id="colors_footer">
<input type="text" value="575757" class="color">
</li>
</ul>
Basically, A bunch of text input types that the values are HEX colors codes
and two of radio input types with "white" and "dark" values
Now with javascript i want to change each of the text input values to different color codes when i click on the "white" or "dark" radio types
For example, If i click on [value="white"]
for colors_body chnage value to FFFFFF
for colors_wrapper change the value to E6E6E6, and so on...
I did try on my own but no matter what i do i always get stuck on changing the the input values, Look in my code if i come close to what i want to accomplish and understand better what i want to do
var colorizer = {
'white': {
'colors_body': 'FFFFFF',
'colors_wrapper': 'E6E6E6',
'colors_footer': 'CCCCCC'
},
'dark': {
'colors_body': 'EBEEF2',
'colors_wrapper': 'B2B5B8',
'colors_footer': '1A2758'
},
};
$( '#radioSettings input[type="radio"]' ).change(function() {
var val = $(this).val();
if (colorizer[val]) {
for (var i in colorizer[val]) {
if ($( '#colors_' + i ).length) {
//IM GETTING STUCK HERE to change each of the values accordingly
}
}
}
});