screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html lang="en"> <head> <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> </head> <body> <div id="app"> <h3>Vue Js Get Access of DOM Element</h3> <button ref="myButton" @click="handleClick">Click me</button> </div> <script type="module"> const app = new Vue({ el: "#app", methods: { handleClick() { // Access the DOM element using $refs const buttonElement = this.$refs.myButton; // Perform operations on the DOM element buttonElement.innerText = 'Clicked!'; } } }); </script> <style scoped> #app { text-align: center; } h3 { color: blue; } button { padding: 10px 20px; background-color: green; color: white; font-weight: bold; cursor: pointer; } button:hover { background-color: darkgreen; } </style> </body> </html>