Home > Back-end >  Update color while drag on color panel
Update color while drag on color panel

Time:09-13

I used all the events from JavaScript to get the color code while drag on color panel. All methods are working fine for certain mouse events. Can anyone guide me to get the color on drag?

function fillElements(ev) {
    color = ev.target.value
    console.log(color);
}
<input onchange="fillElements(event)" type="color" value="#3367d6">

CodePudding user response:

If I understand this correctly, and you want fillElements to be called on drag event inside color selection box, you can use oninput instead of onchange inside <input>.

function fillElements(ev) {
    color = ev.target.value
    console.log(color);
}
<input oninput="fillElements(event)" type="color" value="#3367d6">

  • Related