第14章 工具函数(下)

index.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>工具函数</title>
<script type="text/javascript" src="jquery-1.10.1.js"></script>
<script type="text/javascript" src="demo.js"></script>
<link type="text/css" rel="stylesheet" href="style.css" />
</head>
<body>

<div id="box">
	<span id="pox"></span>
</div>

</body>
</html>

 

style.css

/* CSS Document */
#box{ width:100px; height:100px; background:#c00;}

 

demo.js

$(function(){
	/*
	var arr = [1,2,3];
	alert($.isArray(arr));
	
	var fn = function(){};
	alert($.isFunction(fn));
	
	var obj = {name:'onestopweb'};
	alert($.isEmptyObject(obj));
	
	var obj = {};
	obj = new Object();
	alert(obj);
	obj = window;
	obj = new Object('onestopweb');
	alert(obj);
	alert($.isPlainObject(obj));
	
	alert($.contains($('#box').get(0),$('#pox').get(0)));
	
	//var arr = [1,2,3];
	var obj = {};
	alert($.type(obj));
	
	var num = 1.132;
	alert($.isNumeric(num));
	
	var win = window;
	alert($.isWindow(win));
	
	var obj = {
		name:'onestopweb',
		age : 100
	}
	alert($.param(obj));
	
	alert($.browser);
	
	if($.support.opacity ==true){
		$('#box').css('opacity',0.5);
	}else{
		$('#box').css('filter','alpha(opacity=50)');	
	}
	
	var obj = {
		name : 'onstopweb',
		test : function(){
			alert(this);
			alert(this.name);
		}
	};
	
	//obj.test();
	$('#box').click(obj.test);
	*/
	
	var obj = {
		name : 'onstopweb',
		test : function(){
			//var _this = obj;
			//alert(_this.name);
			alert(this.name);
		}
	};
	
	//obj.test();
	$('#box').click($.proxy(obj,'test'));
	
});

 

 

 

你可能感兴趣的:(函数)