jquery08
<!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的更多相关文章
- jQuery08源码 (5140 , 6057) DOM操作 : 添加 删除 获取 包装 DOM筛选
jQuery.fn.extend({ //$('ul').find('li').css('background','red'); //$('ul').find( $('li') ).css('back ...
- day56 Pyhton 前端Jquery08
前端 内容回顾: -BOM -jquery介绍 -jquery下载和引入方式 npm install jquery -jquery的选择器 -基本选择器 -通配符选择器 - id选择器 - 类选择器 ...
随机推荐
- 再谈Ubuntu和CentOS安装好之后的联网问题(桥接和NAT、静态和动态ip)(博主推荐)
不多说,直接上干货! 首先,普及概念. hostonly.桥接和NAT的联网方式 对于CentOS系统,用的最多的就是,NAT和桥接模式 CentOS 6.5静态IP的设置(NAT和桥接联网方式都适用 ...
- YYDispatchQueuePool阅读笔记
阅读了开源大神的YYDispatchQueuePool,在此记下一些从中学到的东西. 首先YYDispatchQueuePool.m文件中有如下类型对应: static inline dispatch ...
- [POI2002][HAOI2007]反素数 数论 搜索 好题
题目描述: 对于任何正整数x,其约数的个数记作g(x).例如g(1)=1.g(6)=4. 如果某个正整数x满足:g(x)>g(i) 0<i<x,则称x为反质数.例如,整数1,2,4, ...
- php八大设计模式之职责链模式
当发生一种事情时,我们需要要对应职责的事物去处理对应的事情. 或者去找最近的类(就是级别最低的)去解决,如果解决不了就顺着往上找职责更高的,直到解决为止. 注意:一定是要有一个职责最高的类,否则会有问 ...
- python的模块导入机制
在python中用import或者from...import来导入相应的模块. 模块(Module)其实就是一些函数和类的集合文件,它能实现一些相应的功能,当我们需要使用这些功能的时候,直接把相应的模 ...
- linux下python3源码安装及卸载
Linux下Python3的源码编译安装和卸载方法 [日期:2019-06-21] 来源:博客园 作者:wuli潇萧 [字体:大 中 小] (一)Linux下软件的源码编译安装和卸载方法 L ...
- WSGI和CGI
https://www.zhihu.com/question/19998865 https://segmentfault.com/a/1190000003069785
- Unity Shader (四)片段程序示例
1.环境光+漫反射+高光+点光源 Shader "Custom/Example_Frag_1" { properties { _MainColor(,,,) _Specular ...
- 进程:linux用户态-内核态
用户态:Ring3运行于用户态的代码则要受到处理器的诸多检查,它们只能访问映射其地址空间的页表项中规定的在用户态下可访问页面的虚拟地址,且只能对任务状态段(TSS)中I/O许可位图(I/O Permi ...
- [Python] Read and plot data from csv file
Install: pip install pandas pip install matplotlib # check out the doc from site import pandas as pd ...