Is it possible to change the background color and back to the original in plain javascript every time i click a button? -
i can't seem see results on google unless use jquery , i'm not sure if jquery , javascript plain work together.
try using data-*
attribute store color replacement, original background color of button
element or initial
setting; json.parse()
, json.stringify()
, array.prototype.reverse()
toggle data-*
attribute values set background
of input type="button"
element; onclick
event.
not if requirement toggle background color, or reset original color once ?
<input type="button" value="button" data-colors='["blue", "buttonface"]' onclick="this.style.background = json.parse(this.dataset.colors)[0]; this.dataset.colors = json.stringify(json.parse(this.dataset.colors).reverse());" />
Comments
Post a Comment