control属性和placeholder属性

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>control属性</title>
</head>
<body>
      <script>
          function setNum(){
              var lable = document.getElementById("l1");
              var textBox = lable.control;
              textBox.value = "18888888888  ";
          }
      </script>
      <form>
          <label id="l1">
              手机号:
              <input id="txtNum" maxlength="11">
              <small>请输入手机号</small>
          </label>
          <input type="button" value="设置默认值" onclick="setNum()">
      </form>
<!--control属性访问该表单元素-->
      
      <input type="text" placeholder="用户名">
      <input type="text" placeholder="密码">
<!--文本框未输入时,提示输入。当处于编辑编辑状态,去掉模糊状态-->

</body>
</html>

猜你喜欢

转载自blog.csdn.net/qq_42036616/article/details/81608239