`
QuarterLifeForJava
  • 浏览: 176326 次
  • 性别: Icon_minigender_1
  • 来自: 苏州
社区版块
存档分类
最新评论

JavaScript及jQuery学习笔记(1)

阅读更多
最后更新日:2014年11月17日
从本章开始,都将以jquery源码的分析展开。
先来看个自娱自乐的仿jquery的框架(以后都将基于此框架进行新增、修改、删除):
<html>
<head>
<script>
function test(){
	$("#v").say();	
};

(function (window){
	var test = (function(){

		var t = function(id){
			return new test.n.o(id);
		};

		t.n = t.prototype = {
			o   : function(id){
				return {
					say : function(){
						var change = document.getElementById(id.substring(1,id.length));
						change.innerHTML = "我是未来";
						change.style.width = "100%";
						change.style.height = "100%";
						change.style.fontSize = "100px";
						change.style.backgroundColor = "yellow";
					}
				};
			}
		
		};

		return t;
	}());

	window.$ = window.jquery = test;

})(window);
</script>
<style type="text/css">
div{
	background-color:red;
	width:20%;
	height:20%;
}
</style>
</head>
<body>
	<div id="v" onclick="test()">请在此区域内点击我</div>
</body>
</html>
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics