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选择器 - 类选择器 ...
随机推荐
- MVC自定义错误日志异常处理
MVC添加错误日志处理模块很简单,只要写个继承自HandleErrorAttribute的过滤器,重新OnException方法,贴个异常处理代码如下: public class ExceptionA ...
- jsLittle源码封装对象
window.JSLi = ((function(){ var JSLi = function(selector) { return new JSLi.fn.init(selector); }; JS ...
- c#做对比软件
一些 HTML内容比较/文本差异比较 开源代码 1. DiffPlex - a .NET Diff Generator http://diffplex.codeplex.com/SourceCo ...
- caffe(1) 网络结构层参数详解
prototxt文件是caffe的配置文件,用于保存CNN的网络结构和配置信息.prototxt文件有三种,分别是deploy.prototxt,train_val.prototxt和solver.p ...
- Haproxy实现web的页面的动静分离
一.Haproxy概述: 概述:Haproxy是一个开源的高性能的反向代理或者说是负载均衡服务软件之一,由C语言编写而成,支持会话保持.七层处理.健康检查.故障修复后自动加载.动静分离.HAProxy ...
- [转] C# HttpWebRequest 绝技
c# HttpWebRequest与HttpWebResponse绝技 阅读原文 如果你想做一些,抓取,或者是自动获取的功能,那么就跟我一起来学习一下Http请求吧.本文章会对Http请求时的G ...
- 洛谷 P1583 魔法照片
P1583 魔法照片 题目描述 一共有n(n≤20000)个人(以1--n编号)向佳佳要照片,而佳佳只能把照片给其中的k个人.佳佳按照与他们的关系好坏的程度给每个人赋予了一个初始权值W[i].然后将初 ...
- double long float类型读入读出 double取模 fmod
The library of fmod is #include <cmath> #include<cstdio> #include<cstdlib> #includ ...
- FSM的几种策略
FSM是什么?FSM就是Finite(有限) State(状态) 机(Machine)的缩写.(之所以中英文混写,是为了强调学懂FSM的原理是根本,刻意去采用“几段式”的写法并不重要) riple F ...
- 三段式状态机 [CPLD/FPGA]
状态机的组成其实比较简单,要素大致有三个:输入,输出,还有状态. 状态机描述时关键是要描述清楚前面提高的几个状态机的要素,即如何进行状态转移:每个状态的输出是什么:状态转移是否和输入条件相关等. 有人 ...