[Vuejs]-How to concatenate the index passed as a parameter in a function

1👍

You try next code example:

<tr v-for="(item, i) of items" :key="i">
   <td><input type="text" name="hour[]" :id="'hour-' + i"></td>
   <td><input type= "checkbox" name="disable" v-on:click="disabled(i)"></td>
</tr>

function:

disabled(index){    
   $('#hour-' + index).attr('disabled', true);
}

1👍

You don’t have an element with #hour[i]

So you can change input element id

<tr v-for="(item, i) of items" :key="i">
    <td><input type="text" name="hour[]" :id=`hour[${i} ]`></td>
    <td><input type= "checkbox" name="disable" v-on:click="disabled(i)"></td>
</tr>

Leave a comment