【发布时间】:2017-01-26 21:59:23
【问题描述】:
在这个 cod 中按下输入键时如何获取输入文本的值? ..................................................... ....................
<body>
<div id="center">
<div id="boxtop"></div>
<div id="boxdown">
<input type="text" id="txt"/>
<button type="submit" onclick="SaveData()" id="btn" >SEND</button>
</div>
</div>
<script>
function SaveData() {
work = "insert";
chat = $('#txt').val();
$.ajax({
type: "POST",
url: "server.php",
data: "work="+work+"&chat="+chat,
success: function(msg){
$('#txt').val('');
}
});
}
</script>
</body>
【问题讨论】:
标签: javascript html ajax