search

Home  >  Q&A  >  body text

javascript - Ask for advice on jQuery judgment logic?

How to determine that the checkboxes under all other brother elements of the clicked tr are checked?
Please give me some advice!!!

阿神阿神2803 days ago557

reply all(3)I'll reply

  • 过去多啦不再A梦

    过去多啦不再A梦2017-05-19 10:17:03

    var flag = false;
    $("tr").siblings().each(function () {    // 所有兄弟节点
        $(this).find("checkbox").each(function () {    // 兄弟节点下面的所有checkbox      //     如果只有一个的话直接写不用遍历了
            if (this.checked === false) {
                flag = true;
                console.log('不是所有的checked都为true');
            }
        })
    })
    if (!flag) {
        console.log('所有的checked都为true');
    }

    reply
    0
  • 我想大声告诉你

    我想大声告诉你2017-05-19 10:17:03

    By querying parent-tr-siblings and then using for to judge

    reply
    0
  • PHP中文网

    PHP中文网2017-05-19 10:17:03

    Get all tr, maintain an array, click to change the corresponding index status of the array, traverse the array to determine which ones are currently checked

    reply
    0
  • Cancelreply