document.getElementsByClassName('input-wrapper')
结果
有没有办法通过执行dom操作来选择离子列表的第二项?
尝试使用选定的索引不起作用
使用可以选择带索引的第二项,检查片段
var el = document.getElementsByClassName('input-wrapper');
Object.keys(el).forEach(item=>{
el[item].addEventListener('click' ,()=>{
el[item].children[0].checked = !el[item].children[0].checked
console.log(el[item]);
})
})
<div class="input-wrapper">1 label <input type="radio" value="select"> Label</div>
<div class="input-wrapper">2 label <input type="radio" value="select"> Label</div>
<div class="input-wrapper">3 label
<input type="radio" value="select"> Label
</div>
<div class="input-wrapper">4 label <input type="radio" value="select"> Label </div>
<div class="input-wrapper">5 label <input type="radio" value="select"> Label </div>
<div class="input-wrapper">6 label <input type="radio" value="select"> Label </div>