Changing style of a button on click

后端 未结 5 821
执念已碎
执念已碎 2020-12-08 10:25

Is it possible to change background-color of my button onClick function?

ex. click background-color: black, another click

5条回答
  •  Happy的楠姐
    2020-12-08 11:28

    You also have access to event and current target of the event

    handleClick = (event) => {
       // accessible
       event.target.style
       event.target.classList //to change style via css
    }
    

提交回复
热议问题