Categories
Vue Answers

How to call a function as soon as the cursor moves from one text box to next in Vue.js?

Spread the love

Sometimes, we want to call a function as soon as the cursor moves from one text box to next in Vue.js.

In this article, we’ll look at how to call a function as soon as the cursor moves from one text box to next in Vue.js.

How to call a function as soon as the cursor moves from one text box to next in Vue.js?

To call a function as soon as the cursor moves from one text box to next in Vue.js, we can listen to the blur event.

For instance, we write

<template>
  <div id="app">
    <input @blur="handleBlur" placeholder="first name" />
    <input @blur="handleBlur" placeholder="last name" />
  </div>
</template>

to listen to the blur event and run the handleBlur method if the event is triggered with

@blur="handleBlur" 

Conclusion

To call a function as soon as the cursor moves from one text box to next in Vue.js, we can listen to the blur event.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *