Home > Web Front-end > JS Tutorial > body text

jquery foreach usage example_jquery

WBOY
Release: 2016-05-16 17:22:43
Original
1448 people have browsed it
Copy code The code is as follows:










$("input").each(function(index){ //Get the entire The input value of the page

$("input:text").each(function(index){
alert(index);//The subscript value of the loop, starting from 0
alert( this.value); alert($(this).attr("type")); //With its own attributes, you can use this(Dom) to directly get the value
alert($(this).attr("vili") ); //Custom attributes need to use attr(Jquery) to get the value
//if($(this).attr("vili")=="true"&&){
 
//}
});

Copy code The code is as follows:

$.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) ;
}
});
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template