Home >Web Front-end >JS Tutorial >How jquery captures events triggered by the Enter key_jquery

How jquery captures events triggered by the Enter key_jquery

WBOY
WBOYOriginal
2016-05-16 16:51:191209browse

1. jquery captures the Enter key:

Copy code The code is as follows:

$("html ").die().live("keydown",function(event){
if(event.keyCode==13){
//Add the logic to be processed here
}
} );

//Bind carriage return action
$('textarea[name=chattext]').keydown(function(event){
if(event.which==13){

}
});

2.jquery to get multiple selected checkbox values:
Copy code The code is as follows:

$('input[type="checkbox"][name="types"]:checked').each(function() {
types = types $(this).val() "|";
}
);

3.jquery asynchronous request method:
Copy code The code is as follows:

$.ajax({
url : "${pageContext.request.contextPath }/UOSRoleManangerAction.do?method=createRole",
type : "post",
dataType : "html",
data:{"roleName":roleName,"roleDescription":roleDescription,"roles" :roles,"types":types},
success : function(data){
var dataObj=eval("(" data ")");
if(dataObj.result){
alert("Operation successful!");
submitForm(null,"initPage");
}else {
alert("Operation failed!");
}
}
});
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn