This article describes how jquery captures the events triggered by the carriage return key. For more information, see section 1. jquery captures the carriage return key:
The Code is as follows:
$ ("Html"). die (). live ("keydown", function (event ){
If (event. keyCode = 13 ){
// Add the logic to be processed here
}
});
// Bind the carriage return action
$ ('Textarea [name = chattext] '). keydown (function (event ){
If (event. which = 13 ){
}
});
2. jquery obtains multiple checkbox values:
The Code is as follows:
$ ('Input [type = "checkbox"] [name = "types"]: checked'). each (function (){
Types = types + $ (this). val () + "| ";
}
);
3. jquery asynchronous request method:
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! ");
}
}
});