function convertOperate(col,id,state){
//alert('test');
var num=new Array("0","1","3");
var msg=new Array("草稿","待审核","审核不通过");
for(var i=0;i<num.length;i++){
//alert(num[i]+'<----->'+state);
if(num[i]==state){
$("#div_").show(); ---->注意
}
}
return col['operate'];
}
function convertState(col){
var num=new Array("0","1","2","3","4");
var msg=new Array("草稿","待审核","审核通过","审核不通过","已作废");
for(var i=0;i<num.length;i++){
if(num[i]==col['status'])
col['status']=msg[i];
}
return col;
}
显示列就用col
2.循环遍历select:
var selectObj = $("#invtrades option");
for(var i=0;i<selectObj.length;i++)
{
if(selectTrades==selectObj.get(i).value)
{
selectObj.get(i).selected=true;
}
}
3.手机正则表达式:
if(mobilePhone!=null&&mobilePhone!=""){
var reg=/^(/d{2,3}-)?1[3|5|8]/d{9}?$/;
if(!reg.test(mobilePhone)){ ------}注意:和Java不一样reg.matcher(reg)
alert("请输入手机号码!");
return validator;
}
function selectMenu(menuid,subtitleid,submenuid)
{
var menuId = "#leftMenu";
$(menuId).find("dd").hide();
$(menuId).find("dt").removeClass("selected");
var menuObj = document.getElementById(menuid);
var ddObj = menuObj.getElementsByTagName("dd");
ddObj[0].style.display ="block";
for(i=0;i<ddObj.length;i++)
{
ddObj[i].style.display = "";
}
document.getElementById(subtitleid).className="selected";
document.getElementById(submenuid).className ="focus";
}
$("#historyFinance").after("<span class='error_info' style='color:red;'>请输入历史财务数据!</span>");
2.Jquery聚焦:$("#marketAnalysis").focus();
3.jquery单项绑定:(eval)
for(var i=0;i<props.length;i++){
var propValue=eval("invFund."+props[i]);
$("#"+props[i]+"").html(propValue);
}
4. value+=("<li><a target='_blank' onClick=/"callSid('hitService','"+proList[i].projectId+"')/" href='projectDetail.html?projectId="+proList[i].projectId+"'>"+proList[i].projectTitle+"</a></li>");
原数组中大于 0 的元素加 1 ,否则删除。
$.map( [0,1,2], function(n){
return n > 0 ? n + 1 : null;
});
6.<a href="javascript:getOperater('${appId}','${keyWords}' );"
7. var updateToDate = getCalendarValue("toDate");
var txtType1 = $("#appType1 option:selected").text();
if(obj.title.length > 10)
{
obj.title = obj.title.substring(0,20);
obj.title += "...";
}
//随机验证码
function refreshValidCode()
{
var imgObj = document.getElementById("validCodeImg");
var time = new Date().getTime();
imgObj.src = "../../../getValidCodeServlet?time=" + time;
}
var email = /^/w+([-+.]/w+)*@/w+([-.]/w+)*/./w+([-.]/w+)*$/;
Var baPath=document.getElementById("div_certificateAttPath").previousSibling.value;
12.对select进行遍历:
function getCertType(ret)
{
var options = new Array();
options.push("<option value='all'>全 部</option>");
for(var i=0;i<ret.length;i++)
{
options.push("<option value='" + ret[i].dataName + "'>" + ret[i].dataName + "</option>");
}
$("#certificateType").html(options.join(""));
}
13.判断是否是整数:if(!isInteger(amount.value)){
14. if(!(/^[-/+]?/d+$/.test(amount.value))){
alert('充值金额只能是整数');
return;
function getLengthOfChar(char)
{
var len = 0;
for (var i = 0; i < char.length; i++)
{
if (char.charCodeAt(i)>127 || char.charCodeAt(i)==94)
{
len += 2;
} else
{
len ++;
}
}
return len;
}
function funcPasswordValid(myPassword)
{
for (var i = 0; i < myPassword.length; i++)
{
if (!(myPassword.charCodeAt(i) <= 126 && myPassword.charCodeAt(i) >= 33))
{
return false;
}
}
return true;
}
function hideTabs()
{
$("li[name='tdTab'][className != 'on']").each(
function()
{
$('#'+this.childNodes[0].href.split("#")[1]).hide();
}
);
}
function selectTab(o)
{
if("on" != o.className){
$("li[name='tdTab']").each(function(){$(this).removeClass('on')
}
);
hideTabs();
$(o).addClass('on');
$('#'+o.childNodes[0].href.split("#")[1]).show() ;
}
}
var re_title = /[-_/~!@#……¥/$%/^&/*/./(/)/[/]/{/}<>/?/////'/"]/;
if(re_title.test($("#msgTitle").val())){
$("#msgTitle").next("span").next("span").css("color","red");
$("#msgTitle").focus();
return true;
}
$("#messageStatus").html(obj.msgStatus=="0"?"未阅读":"已阅读");
$("#receiveDate").html(formatDate(new Date(obj.receiveDate), "yyyy-MM-dd HH:mm:ss"));
21.对输入的字符做判断:
(1).<td><textarea id="textContainer1" name="salutatory" cols="75" rows="10" onkeyup="checkMaxInput(this,100,'remLen');" onfocus="checkMaxInput(this,100,'remLen');" ></textarea>
<div class="note">剩余字数(包括标点),不超过
<span id="cl"><input readonly type=text name="remLen" id="remLen" value="100" style="border:0;backgroud:#fff;width:25px"/></span>个字符(中文算2个字符)
</div>
<span class="red" id="nocontent"></span>
</td>
(2)用Jquery对输入的文本框进行时刻校验:
function checkMaxInput(_this,maxleng,leftInforId) {
var left=document.getElementById(leftInforId);
var len=_this.value.replace(/[^/x00-/xff]/gi,'xx').length;
var remainnum =parseInt(maxleng)-len;
left.value = remainnum;
if(remainnum < 0) {
if(_this.value.length!=len) {
if((len-_this.value.length)>(maxleng/2)) {
_this.value=_this.value.substring(0,maxleng/2);
}
else {
_this.value=_this.value.substring(0,maxleng-(len-_this.value.length));
}
}else{
_this.value=_this.value.substring(0,maxleng);
}
left.value=0;
return;
}
}
window.location.href='audit.html?ids='+ids+'&type='+type;
window.open("viewSendMsg.html?msgId="+id);
23.Java中面向对象的查询:
if(dao.createCriteria(AppScore.class).add(Expression.eq("memberId", memberId)).add(Expression.eq("appId", appId)).list().isEmpty())
另一个经常碰到的任务是在没有被jQuery覆盖的DOM元素上call一些方法,想像一个在你用AJAX方式成功提交后的reset:
$(document).ready(function() {
// use this to reset a single form
$("#reset").click(function() {
$("#form")[0].reset();
});
});
imgsrc = "../../../images/1-star.gif ";
$("img[id=imgs]").attr("src",imgsrc);