[Vuejs]-Vue js get individual value of hidden input stored in div

0👍

make the ref’s unique

change onclick to send the ref value

<div class="card text-white bg-primary mb-3" style="max-width: 18rem;" @click="sendData('ref1')">
  <div class="card-header">2 Points</div>
  <div class="card-body">
    <h5 class="card-title">
      <input type="number" value="2"  ref="ref1" id="cardValue" hidden />
    </h5>
    <p class="card-text">Some explanation.</p>
  </div>
</div>

change the code to use the sent ref value

methods: {
  sendData(ref) {
    const updatedCardValue = this.$refs[ref]value;

Leave a comment