0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

チェックされたチェックボックスの数を判定し、2つ以上なら対象のボタンを活性化する処理

Last updated at Posted at 2023-05-07
function countChecks() {
    // チェックボックスの要素を取得する
    const el = document.getElementsByClassName("checks");

    let count = 0;
    // チェクボックスの数分ループ
    for (let i = 0; i < el.length; i++) {
        // チェックされている数をカウント
        if (el[i].checked) {
            count++;
        }
    }
    // チェック済みの項目が2個以上の場合、ボタンを活性にする
    if(count >= 2) {
        multiDeleteBtn.disabled = false;
    } else {
        multiDeleteBtn.disabled = true;
    }
};
0
0
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?