document.addEventListener("DOMContentLoaded", function(event) {
button = document.querySelector(".dropbtn");
button.addEventListener("mouseenter", ()=> {_dropmenu('remove')}, false);
dropDown = document.querySelector("#others");
dropDown.addEventListener("mouseleave", ()=> {_dropmenu('add')}, false);
function _dropmenu(par){
dropDown.classList[par]("hidden");
}
window.onclick = function(event) {
if (!event.target.matches('.dropbtn') && !event.target.matches('#others')) {
var dropdowns = document.getElementsByClassName("dropdown-content");
var i;
for (i = 0; i < dropdowns.length; i++) {
var openDropdown = dropdowns[i];
if (openDropdown.classList.contains('hidden')) {
openDropdown.classList.remove('hidden');
}
}
}
}
});
function colorAdd() {
divField = document.createElement('div');
divColorField = document.createElement('div');
divField.classList.add('newField');
divColorField.classList.add('newColorField');
divField.appendChild(divColorField);
divColorField.style.backgroundColor = `rgb(${myForm.R.value}, ${myForm.G.value}, ${myForm.B.value})`;
myForm.after(divField);
}
colorAdding.addEventListener('click', function() {
text = `R = ${myForm.R.value}, G = ${myForm.G.value}, B = ${myForm.B.value}`;
colorFieldText = document.createTextNode(text);
divField.appendChild(colorFieldText);
});