
function fn1(obj){
var $li = $(obj)parent();
var spclass = $lidata("spclass");
}
var arr = [1,2,3,[4,[5,6]]]; //arrlength
Arrayprototypeeach = function(fn){
try{
//1 目的 遍历数组的每一项 //计数器 记录当前遍历的元素位置
thisi || (thisi=0);
//2 严谨的判断什么时候去走each核心方法
//当数组的长度大于 0 的时候 && 传递的参数 必须为函数
if( thislength>0 && fnconstructor == Function ){
// 循环遍历数组的每一项
while( thisi < thislength ){
//获取数组的每一个值
var e = this[thisi]; //数组的每一项
//如果当前元素获取到了 并且当前元素是一个数组
if(e && econstructor == Array ){
//直接递归 *** 作
eeach(fn);
}else{
//如果不是数组 (那就是一个单个元素)
//var obj = true;
//fnapply(obj,[e]);
//这的目的就是为了把数组的当前元素 传递给fn函数,并且让函数执行
fncall(e,e);
}
thisi++
}
thisi == null ; //释放内存 垃圾回收机制回收变量
}
}catch(err){
//do something
}
return this;
}
arreach(function(item){
consolelog(item)
});
jQuery有方法$fnserialize,可将表单序列化成字符串;有方法$fnserializeArray,可将表单序列化成数组。 如果需要其序列化为JSON对象,那么可以基于serializeArray编写方法serializeObject轻松实现:
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="jqueryjs"></script>
<script>
jQuery(function(){
jQueryprototypesmohanfacebox = function(options){
options = jQueryextend({
init:function(){
consolelog('default init');
}
},options);
// call init with each selected element
jQuery(this)each(function(){
optionsinitcall(this);
});
return jQuery(this);
};
// call init function with default define
jQuery('div')smohanfacebox();
// call init function with custom define
jQuery('div')smohanfacebox({
init:function(){
consolelog(jQuery(this)attr('id'));
}
});
});
</script>
</head>
<body>
<div id="1"></div>
<div id="2"></div>
<div id="3"></div>
</body>
</html>
以上就是关于js获取鼠标点击元素当中的信息全部的内容,包括:js获取鼠标点击元素当中的信息、js遍历多维数组(面向对象)、$fn.serializeJson = function 中fn代表什么,谁是函数名等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)