D
D
Dauren S2018-12-19 09:21:39
Vue.js
Dauren S, 2018-12-19 09:21:39

How to count the number of selected elements?

<div id="example-3" class="demo">
  <input type="checkbox" id="jack" value="Джек" v-model="checkedNames">
  <label for="jack">Джек</label>
  <input type="checkbox" id="john" value="Джон" v-model="checkedNames">
  <label for="john">Джон</label>
  <input type="checkbox" id="mike" value="Майк" v-model="checkedNames">
  <label for="mike">Майк</label>
  <br>
  <span>Отмеченные имена: {{ checkedNames }}</span>
</div>

new Vue({
  el: '#example-3',
  data: {
    checkedNames: []
  }
})

Question: how to count the number of selected items and, if any, display a new button?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2018-12-19
@dauren101

<button v-if="checkedNames.length">click me</button>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question