详解: input[type="类型是什么"] 16

核心:记住哈,:required与:optional对单选框和复选框,自己的理解,
无效哈
核心:最核心的点来了
为什么单选按钮要两个name一样的呢?
因为两个name一样代表只能有一个啊,name两个是不是最后一个会覆盖前一个,对了嘛是把
比如两个一样的变量是不是会覆盖成为一个呢,所以一个就是单选按钮啊懂?
复选框为什么要两个都一样?
我的理解是我试来一下,不一样也行,我的理解就是这样,有个性把哈哈哈
其实原因就是复选框的底层原理是数组懂了把哈哈哈

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        input:required
        {
            color: red;
        }
        input:optional
        {
            color: yellow;
        }
       input[type="radio"]:checked
        {
            width: 100px;
            height: 100px;
        }
        input[type="checkbox"]:checked
        {
            height: 100px;
            width: 100px;
        }
    </style>
</head>
<body>
    <form>
        用户名:<input type="text" name="username" id="" placeholder="请输入" required="required" ><br>
        密码:<input type="password" name="password" id="" required="required" placeholder="你输入"><br>
        邮箱:<input type="text" name="email" id="" required="required"  placeholder="请输入"><br>
        年龄:<input type="text" name="age" id="" placeholder="输入"><br>
        性别:<input type="radio" name="sex" id="" value="1">男
        <input type="radio" name="sex" id="" value="2">女
        <input type="radio" name="sex" id="" value="3">保密<br>
        兴趣爱好:
        <input type="checkbox" name="fav[]" id="" value="1" />PHP
        <input type="checkbox" name="fav[]" id="" value="2" />PHP

    </form>
</body>
</html>
原创文章 107 获赞 14 访问量 1360

猜你喜欢

转载自blog.csdn.net/qq_37805832/article/details/105763282
16
今日推荐