M
M
movsumlu2021-03-18 13:37:35
Vue.js
movsumlu, 2021-03-18 13:37:35

VueJS how to check if input is focused (clicked)?

good afternoon,
there is an input with a price and if it is not in focus, then you need to display the placeholder,
if you clicked on it to enter the price, then you don’t need to display it,
I can’t understand a little how you can check that the input is clicked and change the placeholder depending on this at the element?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2021-03-18
@movsumlu

So check it out . Then, accordingly, dynamically assign a placeholder:
:placeholder="focused ? '' : 'hello, world!!'"
In general, js-code is not needed to solve your problem:

input:focus::placeholder {
  color: transparent;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question