Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

175
Views
How to querySelect Vuejs element on click

I want to querySelect the exact element that is click on vueJs

<a @click="myFunc()"> Click Me </a>

And edit this element using js querySelector

methods : {
 myFunc(){
  document.querySelector(this)
 }
}
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

In your case, there is an easier solution than query select.

Html:

<a @click="myFunc"> Click Me </a>

(note that I've removed the ())

Vue:

methods : {
 myFunc(e){
   console.log(e.target)
 }
}

You can use the event generated by the DOM instead of trying to search for the element.

about 4 years ago · Juan Pablo Isaza Report

0

You can use ref:

new Vue({
  el: '#demo',
  data() {
    return {

    }
  },
  methods : {
     myFunc(){
      this.$refs.link.innerText = 'selected'
    }
  }
})

Vue.config.productionTip = false
Vue.config.devtools = false
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="demo">
  <a ref="link" @click="myFunc"> Click Me </a>
</div>

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!