您的位置:首页 > Web前端 > JQuery

使用jQuery中的each(data,function(){});函数

2011-12-21 16:46 411 查看

[转自:http://api.jquery.com/jQuery.each/]  

version added:
1.0

jQuery.each( collection, callback(indexInArray, valueOfElement) )

collectionThe object or array to iterate over.
callback(indexInArray, valueOfElement)The function that will be executed on every object.
The
$.each()
function is not the same as
$(selector).each(), which is used to iterate, exclusively, over a jQuery object. The
$.each()
function can be used to iterate over any collection, whether it is a map (JavaScript object) or an array. In the case of an array, the callback is
passed an array index and a corresponding array value each time. (The value can also be accessed through the
this
keyword, but Javascript will always wrap the
this
value as an
Object
even if it is a simple string or number
value.) The method returns its first argument, the object that was iterated.

 

jQuery AJAX 请求  参见:http://www.w3school.com.cn/jquery/jquery_ajax.asp

请求描述
$(selector).load(url,data,callback)把远程数据加载到被选的元素中
$.ajax(options)把远程数据加载到 XMLHttpRequest 对象中
$.get(url,data,callback,type)使用 HTTP GET 来加载远程数据
$.post(url,data,callback,type)使用 HTTP POST 来加载远程数据
$.getJSON(url,data,callback)使用 HTTP GET 来加载远程 JSON 数据
$.getScript(url,callback)加载并执行远程的 JavaScript 文件
 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息