-1👍
First of all you’re not being very clear what you want to do.
2nd of all you have found solution so just clean up your code.
3rd of all I’d try using el.closest.
const input = document.getElementById('yourInput');
const label = input.closest("label");
// or if you want to add ids to labels
const label2 = input.closest("#yourLabel");
With this solution you will be little bit more save. Couse in yours, lets just imagine that somebody change HTML structure… Then very high risk your code stops working.
- [Vuejs]-In Vue.js, how do I enable buttons in a v-for loop
- [Vuejs]-Deleting record using laravel and vue js
Source:stackexchange.com