Skip to content

Instantly share code, notes, and snippets.

View fengyk1's full-sized avatar

封阳葵 fengyk1

View GitHub Profile
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title></title>
</head>
<script>
//Person类作为所有人的父类
var Person = function(name,sex){
this.name = name;
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title></title>
</head>
<style>
.d_t{width:100px;height:100px;background:red;position:absolute;left:400px;top:200px;transition:.5s all;-webkit-transform:rotate(0deg);}
</style>
<script type="text/javascript" src="jquery-1.7.1.min.js" ></script>
//JQ源码分析1.1-匿名函数
//匿名函数的作用是不受外部干扰、立即执行的意思。假如JQuery直接写全局函数的话、
//要是我们自己写了一个方法跟JQ内部方法重名、就会引起冲突
//对于程序来讲这样并不好
//而匿名函数正好帮我们解决了这个问题、这是javascript的一个特点
//匿名函数有两种执行方式、下面我们来看看
//第一种
/* (function(){
alert('aaaaaa');
jQuery源码分析 - 前言
jQuery凭借简洁的语法和跨平台的兼容性,极大地简化了JavaScript开发开发人员遍历HTML文档、
操作DOM、处理事件、执行动画和开发Ajax的操作。
其独特而又优雅的代码风格改变了JavaScript程序员的设计思路和编写程序的方式。
---摘自《锋利的jQuery》
通过分析JQuery我们可以
学习先进的设计理念
学习各种实现技巧
巩固JavaScript基础
无限的接近那些牛人
//这样来看一下、我们首先创建一个匿名函数、匿名函数会被立即执行
(function(){
var a = 10;
function aa(){
//首先我们在内部函数里面创建一个变量
var b = 20;
//这个变量是可以正常访问的、但是我们在外部调用来试试
console.log(b);
//函数内部我们再嵌一个函数
function cc(){
function getCss(obj, attr)
{
if(attr=="rotate")
{
return obj.rotate;
}
var i=parseFloat(obj.currentStyle?obj.currentStyle[attr]:document.defaultView.getComputedStyle(obj, false)[attr]);
var val=i?i:0;
if(attr=="opacity")
{
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title></title>
<style>
#ul1{width:556px;margin:100px auto;}
#ul1 li{list-style:none;width:150px;height:200px;border:solid 1px #CCC;float:left;margin:10px;transition:.5s background,.3s;-webkit-transform:rotate(10deg);}
#ul1 img{width:150px;height:200px;-webkit-box-shadow:20px 20px 5px #888888;z-index:1;}
</style>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title></title>
<style>
body{padding:0;margin:0;}
div:nth-of-type(1){background:url(images/11.jpg);}
div:nth-of-type(2){
width:300px;
//封装自己的函数库、一个类似Jquery的框架
//给对象注册事件
function myAddEvent(obj,sEv,fn){
if(obj.attachEvent){
obj.attachEvent('on'+sEv,function(){
//call用来改变this指向
if(false == fn.call(obj)){
//阻止冒泡
event.cancelBubble = true;
//阻止默认事件
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title></title>
<style>
*{margin:0;padding:0;}
#div1{overflow:hidden;width:600px;height:400px;margin:20px auto;position:relative;}
#ul1{width:2400px;position:absolute;left:0;}
#ul1 li{list-style:none;width:600px;height:400px;float:left;}