screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html> <head> <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> </head> <body> <div id="app"> <h3> Vue Js Remove Element From Dom or By Id</h3> <div id="myElement" ref="myElement">Welcome to Fontawesomeicons.com</div> <button @click="removeElement">Remove Element</button> </div> <script type="module"> const app = new Vue({ el: "#app", methods: { removeElement() { const element = this.$refs.myElement; element.parentNode.removeChild(element); } } }) </script> <style scoped> #app { text-align: center; padding: 20px; } #myElement { font-size: 24px; font-weight: bold; color: #333; margin-top: 20px; padding: 10px; border: 2px solid #333; } button { margin-top: 20px; padding: 10px 20px; background-color: #333; color: #fff; border: none; border-radius: 4px; cursor: pointer; } </style> </body> </html>