Is it possible to change the background color and back to the original in plain javascript every time i click a button?

前端 未结 2 435
清酒与你
清酒与你 2021-01-29 01:49

I can\'t seem to see any results on google unless I use jQuery and I\'m not so sure if jQuery and javascript plain work together.

2条回答
  •  天命终不由人
    2021-01-29 01:58

    Try using data-* attribute to store color replacement, original background color of button element or initial setting; JSON.parse() , JSON.stringify() , Array.prototype.reverse() to toggle data-* attribute values that set background of input type="button" element; onclick event.

    Not certain if requirement is to toggle background color, or reset to original color once ?

提交回复
热议问题