attr 更加jquery版本 缓存prop
1. 判断checkbox(复选框)是否被选中
很多朋友判断 if($("#id").attr("checked")=="true") 这个是错误的,其实应该是 if($("#id").attr("checked")==true)
if($("#id").is(":checked")== true)
2. 全选
$("[name
= chkItem]:checkbox").attr("checked", true);
3、全不选
$("[name
= chkItem]:checkbox").attr("checked", false);
4. 反选
$("[name
= chkItem]:checkbox").each(function () {
$(this).attr("checked",
!$(this).attr("checked"));
});
5.选中所有奇数
$("[name='checkbox']:even").attr("checked",'true');
6.获得选中的所有值
$("[name='checkbox'][checked]").each(function(){
str+=$(this).val()+""r"n";
})
7、获取单个checkbox选中项(三种写法)
$("input:checkbox:checked").val()
或者
$("input:[type='checkbox']:checked").val();
或者
$("input:[name='ck']:checked").val();
8.获取多个checkbox选中项
$('input:checkbox').each(function()
{
if ($(this).attr('checked') ==true) {
alert($(this).val());
}
});
9.设置第一个checkbox
为选中值
$('input:checkbox:first').attr("checked",'checked');
或者
$('input:checkbox').eq(0).attr("checked",'true');
10.根据索引值设置任意一个checkbox为选中值
$('input:checkbox).eq(索引值).attr('checked', 'true');索引值=0,1,2....
或者
$('input:radio').slice(1,2).attr('checked', 'true');
11、选中多个checkbox同时选中第1个和第2个的checkbox
$('input:radio').slice(0,2).attr('checked','true');
12、根据Value值设置checkbox为选中值
$("input:checkbox[value='1']").attr('checked','true');
清除表单数据。
function claerData(){
//清除表单数据。
$("#login_form").form("clear");
//自定义框架,先不深究
<s:if test="#request.passwordExpire == \"1\"">
$("#user_Cd").val('<s:property value="#request.syuser_Cd" />');
</s:if>
return;
}
//form表单验证_验证form里的属性规则
function login(){
//form表单验证_验证form里的属性规则
var res = $("#login_form").form("validate");
if(!res) {
return false;
}
}
一些新用法ssh
//common
String msgId = chkLoginUser(userList, passwd_Cd, "0");
//存数据,可在前台取出
addActionMessage(msgId);
//前台
//取数据
<s:if test="hasActionMessages()">
<e:msgdialog basepath="<%=basePath%>">
<s:actionmessage />
</e:msgdialog>
</s:if>
字符与字符串
如: char capitalA = 'A';
字符从本质上讲是数字。每一个字符映射到一个范围在0到65 535的正整数,每一个字符在Unicode标准中都有对应的数字值,称为Unicode值。我们可以用如下方法来查看字符的Unicode码:
字符串
字符串对象表示固定长度的字符序列,String类可能是Java程序中使用的最频繁的类了。
来看两种创建字符串的方式:
String a = "abc";
String b = new String("abc");
实际运用中,我们要避免第二种方式,第二种方式创建了两个String对象。首先,Java虚拟机创建了String对象“abc”。然后,java虚拟机创建一个新的String对象,并把字符串“abc”传入构造函数。这是一次完全没有必要的构造,既影响了性能,也提高了代码阅读难度。
由于字符串是字符序列,所以可以嵌入特殊字符。
String s = "\t\n";
详细的String可以上这看
https://www.cnblogs.com/zhuYears/archive/2012/02/06/2339574.html
关于环境变量 Path 的说法
PATH一般是给计算机指定一个寻找路径,举个很简单的例子:
你在开始→运行里输入CMD,电脑会自动打开命令提示符,而cmd.exe程序是在系统的system32目录下,它是怎么找到的?就是通过PATH指引找到的,你输入运行的时候电脑自动在PATH指定的路径里找。