JQuery日记 2014-04.29
2020-12-06 00:52
标签:jquery
JQuery日记 2014-04.29 标签:jquery 原文地址:http://blog.csdn.net/songzheng_741/article/details/24699249$(function(){
var $div = $(‘div‘ );
var args = [":参数" ]
$div.each( function(){
alert( this.id + arguments[0]);
return false ;
},args); //只弹出一次 div1:参 数
});
JQuery.each(obj, callback, args)的源码也比较简单,见注释
// args is for internal usage only
each: function( obj, callback, args ) {
var value,
i = 0,
length = obj.length,
isArray = isArraylike( obj );
//如果有参数
if ( args ) {
//如果是类数组
//则用使用obj[下标]的方式访问迭代的元素
if ( isArray ) {
for ( ; i
Test_Html var $div = $(‘div‘ );
$div.map( function (){
return this .parentNode;
}).each( function (){
alert( this .tagName); //弹出两次 BODY
});
map: function( callback ) {
return this .pushStack( jQuery.map( this, function ( elem, i ) {
return callback.call( elem, i, elem );
}));
},
map: function( elems, callback, arg ) {
var value,
i = 0,
length = elems.length,
isArray = isArraylike( elems ),
//存放结果的数组
ret = [];
// Go through the array, translating each of the items to their new values
if ( isArray ) {
for ( ; i
上一篇:socket抓取网页
下一篇:ExtJS中设置下拉列表不可编辑
文章标题:JQuery日记 2014-04.29
文章链接:http://soscw.com/index.php/essay/23366.html