页面常用Jquery
例一:循环获取指定Id下的子元素如:
<ul id="testul">
<li>John</li>
<li>Karl</li>
<li>Brandon</li>
</ul>
$("#testul li").each(function(){
alert(this);
});
例二:更改Form下的属性值
<html:form styleId="workItemListForm" action="unifyWorkitemListAction" method="post">
<html:hidden property="pageIndex"/>
<html:hidden property="pageCount"/>
<html:hidden property="ascending"/>
<html:hidden property="fieldName"/>
</html:form>
更改pageIndex的值
$("#workItemListForm [name='pageIndex']").attr("value", "1");
或者$("#workItemListForm [name='pageIndex']").val("12");
如需修改action的值:$("#workItemListForm").attr("action","new Action URL");
例三:让鼠标经过表格的行时更改样式,移开时还原
<table id="tblworkItemList" border="1">
<thead>
<tr>
<th>测试测试测试</th>
<th>测试测试测试</th>
</tr>
</thead>
<tbody>
<tr>
<td>测试测试测试</td>
<td>测试测试测试</td>
</tr>
<tr>
<td>测试测试测试</td>
<td>测试测试测试</td>
</tr>
<tr>
<td>测试测试测试</td>
<td>测试测试测试</td>
</tr>
</tbody>
<tfoot>
<tr>
<td>测试测试测试</td>
<td>测试测试测试</td>
</tr>
</tfoot>
</table>
jquery代码:
$("#tblworkItemList > tbody > tr").each(function(i) {
$(this).mouseover(function() {
$(this).addClass("hover");
});
$(this).mouseout(function() {
$(this).removeClass("hover");
});
});
例四:复选框的全选
<input type="checkbox" id="chkSelectAll"/>
<input type="checkbox" name="instanceIds" value="123" >
<input type="checkbox" name="instanceIds" value="456" >
jquery代码:
$("#chkSelectAll").bind("click", {selectId: "instanceIds"}, toggleSelect);
function toggleSelect(event) {
//alert(this.id + ":" + event.data.selectId);
var id = event.data.selectId;
if (id == null) return;
if (this.checked) {
$("input[name='" + id + "']").attr("checked", true);
} else {
$("input[name='" + id + "']").attr("checked", false);
}
}
例五:弹出页面
//g_dialogFeaturesForComment:定义弹出页的样式, vArguments是传入弹出页的值(可以是对象vArguments = new Object(),vArguments.type="test";)
var g_dialogFeaturesForComment = "dialogHeight: 350px; dialogWidth: 400px; center: yes; edge: raised; resizable: no; scroll: yes; status: no;";
retValue= showModalDialog(openurl, vArguments, g_dialogFeaturesForComment);
在弹出页获取传入参数方法为:var obj = window.dialogArguments;
设置弹出页关闭时的返回对象:window.returnValue = retValue; window.close();
Tomcat 乱码,修改URIEncoding:
<Connector URIEncoding="UTF-8" acceptCount="100" connectionTimeout="20000" debug="0" disableUploadTimeout="true" enableLookups="false" maxSpareThreads="75" maxThreads="150" minSpareThreads="25" port="8080" redirectPort="8443"/>
例六:Js 数组下标非固定循环
<script>
var arr=[];
arr["a"]=1;
arr["b"]="a";
for(var o in arr){
document.write(arr[o]+"<br />");
}
</script>
例七:页面Map已知Key取value
<c:set var="key" value="${activityInstance.currentStep}"/>
value的值可以有循环过程中获取
<c:out value="${map[key]}" />
例八:db2 关闭会话 db2 force application (141,164)
141,164 为ID
db2 force application all 关闭所有会话