Jquery binds the carriage return action to capture the event triggered by the carriage return key

  • 2020-03-30 02:30:22
  • OfStack

1. Jquery captures the enter key:
 
$("html").die().live("keydown",function(event){ 
if(event.keyCode==13){ 
//Here add the logic to be processed
} 
}); 

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

} 
}); 

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

3. Jquery asynchronous request method:
 
$.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! "); 
} 
} 
}); 

Related articles: