<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<script src="jquery-2.0.3.js"></script>
<script>
----------------------------------------------------------------------
var str = ' hello ';
alert( '('+$.trim(str)+')' );//前后空格,不包括里面空格,
alert( '('+str.trim()+')' );
----------------------------------------------------------------------
window.onload = function(){ var aDiv = document.getElementsByTagName('div');
console.log( $.makeArray( aDiv ) );//[div,div,div] var s = 123;
console.log( $.makeArray( s ) );//[123]
console.log( $.makeArray( s , {length:3} ) );//Object {3: 123, length: 4} var str = 'hello';
console.log( $.makeArray( str ) );//['hello']
console.log( $.makeArray( str , {length:3} ) );//Object {3: "hello", length: 4} var str = {1:1,2:2};
console.log( $.makeArray( str ) );//[{1:1,2:2}]
console.log( $.makeArray( str , {length:3} ) );//{3:{1:1,2:2},length: 4}
};
---------------------------------------------------------------------------
var arr = ['a','b','c','d'];
alert( $.inArray( 'w' , arr ) ); indexOf ---------------------------------------------------------------------------
console.log($.merge(['a','b'],['c','d']));//["a", "b", "c", "d"]
console.log($.merge(['a','b'],{0:'c',1:'d'}));//["a", "b", "c", "d"]
console.log( $.merge({0:'a',1:'b',length:2},{0:'c',1:'d'}) );//{0: "a", 1: "b", 2: "c", 3: "d", length: 4}
console.log( $.merge({0:'a',1:'b',length:2},['c','d']) );// {0: "a", 1: "b", 2: "c", 3: "d", length: 4}
</script>
</head> <body>
<div></div>
<div></div>
<div></div>
</body>
</html>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<script src="jquery-2.0.3.js"></script>
<script>
------------------------------------------------------------------------
var arr = [1,2,3,4];
arr = $.grep( arr , function( n , i ){//n是每一项,i是下标
return n>2;
} , true );
console.log( arr );//[1,2] var arr = [1,2,3,4];
arr = $.grep( arr , function( n , i ){//n是每一项,i是下标
return n>2;
});
console.log( arr );//[3,4]
------------------------------------------------------------------------
var arr = [1,2,3,4];
arr = $.map( arr , function(n){
return [n+1];
} );
console.log( arr );//[2,3,4,5]
------------------------------------------------------------------------
</script>
</head> <body>
</body>
</html>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<script src="jquery-2.0.3.js"></script>
<script>
$(function(){
function show(){
alert(this);
}
$('input:eq(0)').click( show );
$('input:eq(1)').click(function(){
$('input:eq(0)').off();//取消第一个的绑定
});
}); $(function(){
function show(){
alert(this);
}
$('input:eq(0)').click( $.proxy(show,window) );//改变show的this是window,
$('input:eq(1)').click(function(){
$('input:eq(0)').off();//取消第一个的绑定
});
}); -------------------------------------------------------------------------- function show(n1,n2){
alert(n1);
alert(n2);
alert(this);
}
show();//window
$.proxy(show,document)(3,4);//改变show的this是document,执行,$.proxy()返回值是一个函数名函数地址,加小括号返回的函数才执行,
$.proxy(show,document,3)(4);//改变show的this是document,执行,
$.proxy(show,document,3);//不执行,返回函数地址, var obj = {
show : function(){
alert(this);
}
};
$(document).click( obj.show );//this是document
$(document).click( $.proxy(show,obj) );//this是obj $(document).click( $.proxy(obj,'show') );//让obj下面的show指向obj
//$.proxy(obj,'show') -> $.proxy(obj.show,obj) </script>
</head> <body>
<input type="button" value="点击">
<input type="button" value="取消绑定">
</body>
</html>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<script src="jquery-2.0.3.js"></script>
<script> $().css(); $().attr(); set/get $(function(){
alert( $('#div1').css('width') );
$('#div1').css('background','yellow');
$('#div1').css('background','yellow');
$('#div1').css('width','300px');
$('#div1').css({ background : 'yellow' , width : '300px' });
alert( $.now() );//1970年的时间
(new Date()).getTime()
}); </script>
</head> <body>
<div id="div1" style="width:100px; height:100px; background:red">aaaa</div>
</body>
</html>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<script src="jquery-2.0.3.js"></script>
<script> $(function(){
alert( $('#div1').width() );//display:none还是获取到了,利用的是swap方法
alert( $('#div1').get(0).offsetWidth );//原生的宽度方法,display:none就获取不到了 function show(){
arguments.length
}
show(1,2,3,4);
}); </script>
</head> <body>
<div id="div1" style="width:100px; height:100px; background:red;display:block; visibility:hidden; position:absolute;">aaaa</div>
</body>
</html>

jquery08的更多相关文章

  1. jQuery08源码 (5140 , 6057) DOM操作 : 添加 删除 获取 包装 DOM筛选

    jQuery.fn.extend({ //$('ul').find('li').css('background','red'); //$('ul').find( $('li') ).css('back ...

  2. day56 Pyhton 前端Jquery08

    前端 内容回顾: -BOM -jquery介绍 -jquery下载和引入方式 npm install jquery -jquery的选择器 -基本选择器 -通配符选择器 - id选择器 - 类选择器 ...

随机推荐

  1. 84.Node.js -Mongoose 方法

    转自:https://www.cnblogs.com/chris-oil/p/9136534.html Mongoose 参考手册 标签(空格分隔): MongoDB Mongoose 是什么? 一般 ...

  2. 13.MongoDB 连接命令格式

    转自:https://www.linuxidc.com/Linux/2016-03/129456.htm 使用用户 admin 使用密码 123456 连接到本地的 MongoDB 服务上.输出结果如 ...

  3. Mvc前后端显示不同的404错误页

    最近做的系统前端是移动端的,后端是PC端,然后404页面不能用通一个,so  查找了一些资料,找到了一个解决办法 在Global.asax文件夹下添加Application_EndRequest事件处 ...

  4. 3.Linux系统信息

    arch 显示机器的处理器架构(1) uname -m 显示机器的处理器架构(2) uname -r 显示正在使用的内核版本 dmidecode -q 显示硬件系统部件 - (SMBIOS / DMI ...

  5. Android 自定义viewpager 三张图片在同一屏幕轮播的效果

    github:https://github.com/nickeyCode/RoundImageViewPager 说实话不知道怎么描述这个效果,在网页上见得跟多,公司要求做这个效果得时候不知道怎么用文 ...

  6. .NET简谈——跨进高级编程门槛的必经之路

    我们继续C#基础知识的学习,这篇文章对前面基础知识学习的朋友有着举足轻重的作用:为了延续基础知识学习的热情,我编写了这篇特殊的文章. 本篇文章的中心是想借“.NET简谈反射(动态调用)”一文继续发挥下 ...

  7. 我所理解的monad(1):半群(semigroup)与幺半群(monoid)

    google到数学里定义的群(group): G为非空集合,如果在G上定义的二元运算 *,满足 (1)封闭性(Closure):对于任意a,b∈G,有a*b∈G (2)结合律(Associativit ...

  8. datable

    $("#table_d").append("<table id='dmglTable' class='table table-striped table-hover ...

  9. 洛谷P3402 【模板】可持久化并查集

    一定注意每一次都要是 $root[cur]=root[cur-1]$,不然进行合并时如果 $a,b$ 在同一集合中就会使 $root[cur]=0$. Code: #include <cstdi ...

  10. 记intel杯比赛中各种bug与debug【其二】:intel caffe的使用和大坑

    放弃使用pytorch,学习caffe 本文仅记录个人观点,不免存在许多错误 Caffe 学习 caffe模型生成需要如下步骤 编写network.prototxt 编写solver.prototxt ...