<!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. python中对单例模式的理解

    class Foo(object): instance = None def __init__(self): pass def process(self): ' @classmethod #版本1单例 ...

  2. jzoj3454 表白(love)解题报告(01分数规划+DP)

    题目链接:https://jzoj.net/senior/#contest/show/2414/2 题目描述: 鸡腿是CZYZ的著名DS,但是不想追妹子的DS不是好GFS,所以鸡腿想通过表白来达到他追 ...

  3. 状态压缩dp初学__$Corn Fields$

    明天计划上是要刷状压,但是作为现在还不会状压的\(ruoruo\)来说是一件非常苦逼的事情,所以提前学了一下状压\(dp\). 鸣谢\(hmq\ juju\)的友情帮助 状态压缩动态规划 本博文的大体 ...

  4. Hadoop框架基础(五)

    ** Hadoop框架基础(五) 已经部署了Hadoop的完全分布式集群,我们知道NameNode节点的正常运行对于整个HDFS系统来说非常重要,如果NameNode宕掉了,那么整个HDFS就要整段垮 ...

  5. Intellij格式化java和xml

    使用Intellij的这段时间,一直在寻找一些技巧,不断提高对它的熟练度.接下来告诉大家一个小秘密,带大家体验一下Intellij半自动格式化代码的快感.那要使用这个功能还得安装一个插件--Eclip ...

  6. javascript 优秀写法

    http://www.csdn.net/article/2014-01-06/2818025-Useful-JavaScript-Tips-Best-Practices

  7. hive parquet table 配置使用压缩

    创建parquet table : create table mytable(a int,b int) STORED AS PARQUET; 创建带压缩的parquet table: create t ...

  8. Zero-input latency scheduler: Scheduler Overhaul

    Scheduler Overhaul, with contributions from rbyers, sadrul, rjkroege, sievers, epenner, skyostil, br ...

  9. CF981C(菊花图)

    题目描述 RAMESS知道很多关于树的问题(无循环的无向连通图)! 他创建了一个新的有用的树的划分,但他不知道如何构造它,所以他请求你的帮助! 划分是从树上的边中分裂出一些简单的路径,使得每个两条路径 ...

  10. Python对象的循环引用问题

    目录 Python对象循环引用 循环引用垃圾回收算法 容器对象 生成容器对象 追踪容器对象 结束追踪容器对象 分代容器对象链表 何时执行循环引用垃圾回收 循环引用的垃圾回收 循环引用中的终结器 pyt ...