How to get element by id in vue js?

By Hardik Savani | December 1, 2018 | Category : Vue.JS

I will teach you how to get element by id in vuejs app. this example will help you to get element by id using refs in vue js app.

If you are a using simple jquery and you require to change text or replace content of specific element then you can do it easily. In vue js you can't do it very simple, but you can do it using refs variable.

So, just see bellow example and learn about that:


<!DOCTYPE html>



<title>How to get element by id in vue js? -</title>

<script src=""></script>



<div id="app">

<div id="myId" ref="myId">{{ message }}</div>

<button @click="myFunctionClick()">Click Here</button>



<script type="text/javascript">

new Vue({

el: '#app',

data: {




myFunctionClick: function () {

this.$refs.myId.innerText = 'Hello Bro';






I hope it can help you....

Hardik Savani
My name is Hardik Savani. I'm a full-stack developer, entrepreneur and owner of Aatman Infotech. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.
Follow Me: Github Twitter
***Do you want me hire for your Project Work? Then Contact US.

We are Recommending you: