jQuery工具函数
来源:互联网 发布:linux 查看文件 命令 编辑:程序博客网 时间:2024/05/17 07:57
<!doctype html><html><head><meta charset="utf-8"><title>工具函数</title><script src="../websites/jquery-3.1.0.min.js"></script></head><body><div id="show" style="width:100px; height:100px; background:red"> <p id="ow"></p></div></body></html><script>$(function(){//遍历数组、对象var arr = ['鸣人','佐助','小樱','卡卡西','伊鲁卡']; $.each(arr,function(index,value){$('#show').html($('#show').html()+(index+1)+'.'+value+'<br>');})*//遍历对象$.each($.ajax(),function(name,fn){$('#show').html($('#show').html()+name+fn+'<br>');})//数据筛选var arr = [2,4,6,8,9,10,15,18];var arrGrep = $.grep(arr,function(element,index){return index<5&&element>8;}) alert(arrGrep);//数据修改var arrMap = $.map(arr,function(element,index){//return element;//返回所有数据if(index<5 && element >8){return element+1;//修改数据}})alert(arrMap);//查找数据的索引(可用来判断数据是否在一个数组内)alert($.inArray(11,arr));//如果存在,返回该数据在数组中的索引//合并数组var arr1 = [200,300];var new_arr = $.merge(arr,arr1);alert(new_arr);
//数组去重
$.unique();
//判断一个节点是否被另一个节点包含alert($.contains($('#show').get(0),$('#ow').get(0)));//判断数据类型alert($.type(arr));//判断是否为数字var num = 1;alert($.isNumeric(num));//URL操作var obj = {name:'Lee',age:100}alert($.param(obj));//转化成URL的字符串//调整this指向问题var obj = {name :'Lee',test :function(){alert (this);alert (this.name);}}//obj.test();$('#show').click($.proxy(obj,'test'));})</script>
0 0
- Jquery(九)jquery工具函数
- jQuery使用工具函数
- jQuery 工具函数
- 14.jQuery 工具函数
- jquery-工具函数
- jQuery--工具函数
- jquery工具类函数
- Jquery 工具类函数
- jQuery工具函数
- JQuery 工具函数
- jQuery工具函数
- jQuery 工具类函数
- jQuery 工具函数
- JQuery工具函数汇总
- jQuery工具函数
- jQuery之工具函数
- JQuery工具函数
- JQuery工具函数汇总
- 欢迎使用CSDN-markdown编辑器
- 游标使用注意事项
- 数据库篇
- 利用SSH传输文件
- 结构体位域
- jQuery工具函数
- MFC文档序列化实现保存和加载
- [一]制作U盘安装盘,安装rehl6.4,下载IC工具链,mount ntfs格式的移动硬盘
- Effetive Objective - C 1.Objective 29 - 35 内存管理
- POJ 2195:Going Home(SPFA最小费用最大流)
- VS 2015 c++ exe 独立运行的设置
- MTK平台下Battery驱动分析
- 数列问题 HDU 5806 (尺取法)
- 挂载为什么这么写mount /dev/cdrom /mnt/qwer/