如何使用 jQuery 清除 HTML 表单字段?
jqueryweb developmentfront end technology
使用 jQuery,您可以轻松清除 HTML 表单字段。为此,请使用 jQuery:reset 选择器。这将清除 HTML 表单字段。

示例
您可以尝试运行以下代码,使用 jQuery 清除表单字段 −
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$(":reset").css("background-color", "#F98700");
});
</script>
</head>
<body>
<form action="">
Student Name<br><input type="text" name="sname"><br>
Student Subject<br><input type="password" name="ssubject"><br>
<input type="submit" value="Submit"><br>
<input type="reset" value="Reset">
</form>
</body>
</html>

