$("#username").val();显示:undefined
html:<!DOCTYPEhtml><html><head><metacharset="utf-8"><title></title><linkrel="styleshe...
html:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/reg_log.css">
<script type="text/javascript" src="js/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="js/reg_log.js"></script>
</head>
<body>
<form role="form" action="" method="" id="form">
<h1>建筑自学网注册</h1>
<div class="form-group">
<label for="username">用户名:</label>
<input type="text" name="username" class="form-control" id="username" placeholder="请输入用户名" value="a" required="required">
</div>
</form>
</body>
</html>
js:
(function()
{
'use strict';
var form = $("#form"),
username = $("#username"),
usernameVal = username.val();
alert(usernameVal);
})()
显示:undefined 展开
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/reg_log.css">
<script type="text/javascript" src="js/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="js/reg_log.js"></script>
</head>
<body>
<form role="form" action="" method="" id="form">
<h1>建筑自学网注册</h1>
<div class="form-group">
<label for="username">用户名:</label>
<input type="text" name="username" class="form-control" id="username" placeholder="请输入用户名" value="a" required="required">
</div>
</form>
</body>
</html>
js:
(function()
{
'use strict';
var form = $("#form"),
username = $("#username"),
usernameVal = username.val();
alert(usernameVal);
})()
显示:undefined 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询