我陷入了這個小問題:我只是無法理解如何從每個輸入表單獲取值並將其連接。例如,如果在一個表單中我會寫「Hello」,而在另一個「World」中,它應該在.results類的div中返回「Hello World」。提前致謝!獲取輸入表單值並將其連接起來
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<style>
</style>
</head>
<body>
<input type=text value=""/>
<input type=text value=""/>
<input type=text value=""/>
<input type=text value=""/>
<div class="results"></div>
</body>
<script>
$(document).ready(function() {
$('input').keyup(function() {
$('.results').html('<b>' + $(this).val() + '</b>');
});
});
</script>
</html>
任何原因,你正在使用的4個輸入什麼是表面上一個值? –
順便說一句,你有多個輸入,或多個表單標籤(多輸入)? – sinisake