首页 > 语言 > JavaScript > 正文

jquery foreach使用示例

2024-05-06 15:51:52
字体:
来源:转载
供稿:网友
jquery中的foreach想必大家并不陌生吧,使用jquery的朋友肯定会很熟悉,本文有个不错的示例大家不妨可以巩固一下

复制代码 代码如下:


<form action="${pageContext.request.contextPath}/transfer/input_salary.shtml">
<input type="text" vili="true" onkeyup="formatBankNo(this)"/>

<input type="text" vili="true" onkeyup="formatBankNo(this)"/>

<input type="text" 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);
}
});

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表

图片精选