jquery foreach使用示例
发布时间:2014-03-31 编辑:jiaochengji.com
jquery中的foreach想必大家并不陌生吧,使用jquery的朋友肯定会很熟悉,本文有个不错的示例大家不妨可以巩固一下
复制代码 代码如下:
<form id="input_iForm" action="${pageContext.request.contextPath}/transfer/input_salary.shtml">
<input type="text" class="input_w150" vili="true" onkeyup="formatBankNo(this)"/>
<input type="text" class="input_w150" vili="true" onkeyup="formatBankNo(this)"/>
<input type="text" class="input_w150" vili="true" onkeyup="formatBankNo(this)"/>
</form>
$("input").each(function(index){ //取得整个页面的input值
$("input:text").each(function(index){
alert(index);//循环的下标值,从0开始
alert(this.value); alert($(this).attr("type")); //自带属性可以用this(Dom)直接取值
alert($(this).attr("vili")); //自定义属性需要用attr(jquery)取值
//if($(this).attr("vili")=="true"&&){
//}
});
复制代码 代码如下:
$.ajax({
url: '<%=basePath%>schedule/getMonthRecordLs.action',
dataType: 'json',
success: function(data) {
var events = [];
$(data).each(function(i,val) {
events.push({
id: val.sc_id,
title: val.sc_planemp,
start: new Date(val.sc_date),
color: val.sc_classes=='1'?'':'#993300'
});
});
callback(events);
}
});
您可能感兴趣的文章:
jquery foreach使用示例
php foreach循环中使用引用的问题分析
php array中foreach语句用法举例
jsp中foreach与for循环使用实例
smarty中拼接字符串的方法详解
php遍历数组的几种方法(for foreach list each while)
php遍历数组之list foreach each用法总结
php数组遍历(foreach,list,each)实例演练
使用jquery获取css的值
php遍历数组 foreach each() list()方法总结
[关闭]