Button Click Temporarily Changes Div Background Color, Not Permanently As Intended
I have a div which holds 2 input fields and buttons to change the background color of the div on click, the problem is when I click on the buttons(each one represents a color), the
Solution 1:
for (var i in noteColourArray) {
    // build the button with pure JS just cause it's faster
    var button = document.createElement('button'),
        buttonText = document.createTextNode(noteColourArray[i]);
    button.className = 'colourSelect';
    button.appendChild(buttonText);
    // append the button
    noteCreate.noteForm.append(button);
}
$('.colourSelect').each(function(index, element) {
    $(this).on('click', function(e) {
        e.preventDefault();
        $("#noteCreateContainer").css("background-color", noteColourArray[index]);
    });
});
Post a Comment for "Button Click Temporarily Changes Div Background Color, Not Permanently As Intended"