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

131
Views
Get innerHTML via clicking on a div tag in vue3

I want to get a number between a div tag that is generated via v-for attribute in vue3 when click event happens. How to do that ?

<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

Just catch the event target in the method and do what you want on text content :

<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

You can simply use

<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!