$(function () {
$('#cmd').bind('keydown', function (evt) {
if (evt.keyCode === 13) {
//* I want to call the function here *//
}
});
});
这是我想用参数调用的函数。
$(function (String msg) {
var cmdStr = msg;
$.ajax({
url: 'exec.php',
dataType: 'text',
data: {
q: cmdStr
},
success: function (response) {
$('#txtOut').append(response);
}
});
}
});
});
最佳答案
$('#cmd').keydown(
function (event){
if(event.keyCode == 13){
event.preventDefault();
/*you can call your function here*/
$.ajax({
url: "exec.php",
method: "get",
dataType: "text",
data: { q: $('#com').val()},
success: function(data){
$('#txtOut').append(response);
}
});
/*still you can it here*/
}
}
);
关于jquery - 在 jQuery 函数内调用外部函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5701624/