html表单
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<form name="form" action="" method="get">
<input type="text" name="subject" id="subject" value="Car Loan">
</form>
</body>
</html>
php
<?php echo $_GET['subject']; ?>
有一种表格,它只有在按下回车时才传输数据,如何让它不通过按下回车键,而是在输入时立即传递数据?
我也做了不同的事情:
<form name="form" action="" method="get">
<input type="text" name="subject" id="input" value="Car Loan"><span id="result"></span>
</form>
<script>
input.oninput = function() {
result.innerHTML = input.value;
};
</script>
<h1>
<?php echo $_GET['subject']; ?>
</h1>
我确实喜欢这个,但数据没有传输到 php
您最好的选择是在发送之前添加延迟。例如去抖动