B
B
BtchBetterHaveMyMoney2020-05-13 13:15:29
React
BtchBetterHaveMyMoney, 2020-05-13 13:15:29

How to change checkbox text on click?

https://codepen.io/loozmax/pen/ExVRaew?editors=0010

For some reason it doesn't work. Tried the same with the label, but it only changes the text when you click on it.
Help me please! I'm quite new

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
shsv382, 2020-05-13
@BtchBetterHaveMyMoney

The checkbox does not have its own text, wrap the input in a label and insert text into it

<label><input onClick={this.changeTitle} type='checkbox' value={!this.state.clicked ? 'lf' : 'ytn'} />{!this.state.clicked ? 'lf' : 'ytn'} </label>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question