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

132
Views
Obtenga innerHTML haciendo clic en una etiqueta div en vue3

Quiero obtener un número entre una etiqueta div que se genera a través del atributo v-for en vue3 cuando ocurre un evento de click . Como hacer eso ?

 <template> <div @click="doSth" class="days" v-for="n in 7" :key="n">{{n}}</div> </template> <script> methods : { doSth() { // get {{n}} from inside a div tag when clicking on it and do something on it. } } </script>
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Simplemente capture el objetivo del evento en el método y haga lo que quiera con el contenido del texto:

 <template> <div @click="doSth" class="days" v-for="n in 7" :key="n">{{n}}</div> </template> <script> methods: { doSth(event) { // Let says that you want to add 10 to the "n" number displayed in the div you clicked on : event.target.textContent = parseInt(event.target.textContent) + 10; } } </script>
about 4 years ago · Juan Pablo Isaza Report

0

Simplemente puede usar

 <div @click="doSth(n)" class="days" v-for="n in 7" :key="n">{{n}}</div>
 methods : { doSth(n) { console.log(n) } }
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!