Я наверное не смогу все объяснить, посмотри...
это мой учебный преокт
https://github.com/Sunantby/my-projects/tree/for-forum
data.js
'use strict';
var playerEyes = document.querySelector('.overlay').querySelector('.wizard-eyes');
var playerCoat = document.querySelector('.overlay').querySelector('.wizard-coat');
var playerFireball = document.querySelector('.overlay').querySelector('.setup-fireball');
var inputColorCoat = document.querySelector('.input-color-coat');
var inputColorFireball = document.querySelector('.input-color-fireball');
var inputColorEyes = document.querySelector('.input-color-eyes');
playerFireball.setAttribute('style', 'background-color:#ee4830');
(function() {
window.writeObj = function() {
playerColorsSetup.coat = inputColorCoat.value;
playerColorsSetup.fireball = inputColorFireball.value;
playerColorsSetup.eyes = inputColorEyes.value;
};
window.writeSetup = function () {
playerCoat.style.fill = playerCoat.style.fill || 'rgb(101, 137, 164)';
playerEyes.style.fill = playerEyes.style.fill || 'blue';
playerFireball.style.backgroundColor = playerFireball.style.backgroundColor || '#ee4830';
};
window.writeForm = function () {
inputColorCoat.value = playerCoat.style.fill;
inputColorEyes.value = playerEyes.style.fill;
inputColorFireball.value = playerFireball.style.backgroundColor;
};
})();
// выбираем цвет нашего игрока
window.writeSetup();