jquery foreach

来源:互联网 发布:linux手动添加用户 编辑:程序博客网 时间:2024/06/07 23:18
Js代码
  1. <form id="input_iForm" action="${pageContext.request.contextPath}/transfer/input_salary.shtml">  
  2.    
  3.   <input type="text" class="input_w150" vili="true" onkeyup="formatBankNo(this)"/>  
  4.    
  5.       <input type="text" class="input_w150" vili="true" onkeyup="formatBankNo(this)"/>  
  6.    
  7.       <input type="text" class="input_w150" vili="true" onkeyup="formatBankNo(this)"/>  
  8.    
  9. </form>  
  10.    
  11.    
  12.    
  13.    
  14.    
  15. $("input").each(function(index){ //取得整个页面的input值  
  16.    
  17. $("input:text").each(function(index){  
  18.   alert(index);//循环的下标值,从0开始  
  19.   alert(this.value);  alert($(this).attr("type"));  //自带属性可以用this(Dom)直接取值  
  20.   alert($(this).attr("vili"));                               //自定义属性需要用attr(Jquery)取值  
  21.   //if($(this).attr("vili")=="true"&&){  
  22.        
  23.   //}  
  24.  });   

 

 

 

Js代码
  1. $.ajax({  
  2.       url: '<%=basePath%>schedule/getMonthRecordLs.action',  
  3.       dataType: 'json',  
  4.       success: function(data) {  
  5.           var events = [];  
  6.           $(data).each(function(i,val) {  
  7.               events.push({  
  8.                 id: val.sc_id,  
  9.                   title: val.sc_planemp,  
  10.                   start: new Date(val.sc_date),  
  11.                   color: val.sc_classes=='1'?'':'#993300'  
  12.               });  
  13.           });  
  14.           callback(events);  
  15.       }  
  16.   }); 
原创粉丝点击