1 回答
TA贡献1795条经验 获得超7个赞
您使用的语法不正确,括号的位置不正确,请尝试以下操作:
$(function() {
$('input:text:first').focus();
var $inp = $('input:text');
$inp.bind('keydown', function(e) {
//var key = (e.keyCode ? e.keyCode : e.charCode);
var key = e.which;
if (key == 13) { // Enter key is pressed
e.preventDefault(); // Prevent the default behaviour of enter key
var nxtIdx = $inp.index(this) + 1;
$(":input:text:eq(" + nxtIdx + ")").focus();
// Ajax query to send request to php
var test = $("#command-text").val();
var inputtext = test;
var command = "1";
// var mode = $(".common-input mb-20").val();
$.ajax({
type: "POST",
url: "controller.php",
data: {
inputtext: inputtext,
command: command
},
cache: false,
success: function(html) {
var feedback = "@" + $("#command-text").val() + "#";
$("#feedback").val(feedback);
}
});
}
});
});
- 1 回答
- 0 关注
- 69 浏览
添加回答
举报