![](/img/trans.png)
[英]When two checkboxes are on the same page using the same class name, how do I check the box I want using nightmarejs?
[英]I am creating a to do list using javascript. I want to make it so that when the check box is check/unchecked it adds/removes a class
我正在使用 javascript 創建一個待辦事項列表。
待辦事項列表有一個輸入字段,它創建一個帶有復選框的 div、我輸入的文本和一個刪除按鈕。
我想這樣當復選框被選中/取消選中時,它會添加/刪除 class。
使用 getElementById 獲取元素,然后使用 className 更改元素的 class。
let someElement = document.getElementById('some-elem');
if(condition)
someElement.className += ' class';
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.