screen_rotation
Copied to Clipboard
<html> <head> <script type="importmap"> { "imports": { "vue": "https://unpkg.com/vue@3/dist/vue.esm-browser.js" } } </script> </head> <body> <div id="app"> <h3>Vue Js focus() Method</h3> <p>Set focus on Input element in Vue Js</p> <input ref='inputText' type="text" /><br><br> <button @click="getFocus">Get Focus</button> <button @click="loseFocus">Lose Focus</button> </div> <script type="module"> import { createApp } from "vue"; createApp({ methods: { getFocus() { this.$refs.inputText.focus() }, loseFocus() { this.$refs.inputText.blur(); } } }).mount("#app"); </script> </body> </html>