Loading

拿到checkbox的值

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<form name="form1">
    <div>
        <label for="username">姓名</label>
        <input id="username" value="zyz">
    </div>
    <div>
        <label >密码</label>
        <input name="password" value="123">
    </div>
    <div>
        <input type="radio" name="radio1" >
        <input type="radio" name="radio1">
        <input type="radio" name="radio1">
    </div>
    <div>
        <input type="checkbox" name="checkbox1" value="c1">
        <input type="checkbox" name="checkbox1" value="c2" checked>
        <input type="checkbox" name="checkbox1" value="c3">
    </div>
    <button id="btn">按钮</button>
</form>

<script>
    const checkbox = document.form1.checkbox1
    for(let i=0; i < checkbox.length; i++){
        console.log(checkbox[i].checked)
    }
</script>
</body>
</html>
posted @ 2024-11-23 16:04  一只大学生  阅读(1)  评论(0编辑  收藏  举报