title: How to get an Element by Id in Vue?
body: <p>I would like to get an outer <a href="https://developer.mozilla.org/en-US/docs/Web/API/Element" rel="nofollow noreferrer"><code>Element</code></a> in Vue, using <a href="https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementById" rel="nofollow noreferrer"><code>getElementById()</code></a>:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>new Vue({
    el: "#vue",
    data: {
      helloElement: document.getElementById('hello')
    }
  })</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.2/vue.js"&gt;&lt;/script&gt;
  &lt;div id="hello"&gt;
    hello
  &lt;/div&gt;
  &lt;div id="vue"&gt;
    {{helloElement}}
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>This brings me an empty <code>Element</code>, but not a <code>null</code> - which suggests that the query was partially successful (something was found).</p>
  
  <p>This is actually a POC for a more general problem I face: the ability to get an outer <code>Element</code> (say, a container <code>div</code>) from within a Vue component (this brings me a <code>null</code>, which <a href="https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementById#Return_Value" rel="nofollow noreferrer">the documentation says</a> to be the response when the element was not found).</p>
  
  <p><strong>Is it possible, from within a Vue object or component, to query an outside <code>Element</code> present in the DOM?</strong></p>