J
J
jeka-32020-09-07 14:53:09
React
jeka-3, 2020-09-07 14:53:09

How to change input type on button click?

How to change type in input on button click? For example from type="password" to type="text"

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
Tigran Abrahamyan, 2020-09-07
@jeka-3

K
Kirill Makarov, 2020-09-08
@kirbi1996

You create a state const [isType, setIsType] = useState(true)
When you click, you call a function
In which setIsType(s = !s)
And in the input you write type={isType ? "password" : "text"}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question