Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

有些小的错误 #13

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
border: 2px solid #666;
}
</style>
<script type="text/javascript" src="../jquery-2.1.1.js"></script>
<script type="text/javascript" src="../../jquery-2.1.1.js"></script>
</head>
<body>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@
var event = new Event(originalEvent);

//混入事件属性
i = props.length;
var i = props.length;
var prop;
while (i--) {
prop = props[i];
event[prop] = originalEvent[prop];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<!-- <script src="http://code.jquery.com/jquery-latest.js"></script> -->
<script type="text/javascript" src="../jquery-2.1.1.js"></script>
<title></title>
</head>
Expand All @@ -17,15 +17,16 @@
// 这里关系到一个extentd第一个参数 是否深度复制的处理

var object1 = {
banana: {weight: 52, price: 100},
banana: {weight: 52, price: 100}
};
var object2 = {
banana: {price: 200}
};

$.extend(object1, object2); //结果object1 = {banana: {price: 200}}
$.extend(ture,object1, object2); //结果object1 = {banana: {price: 200,weight: 52}}

$.extend(true,object1, object2); //结果object1 = {banana: {price: 200,weight: 52}}
//打印的结果与你写的结果不一致,原因未知
console.log(object1,object2);//结果{banana: {price: 200}} {banana: {price: 200}}
// 根据这个结果就能清楚的看到jQuery是为了判断克隆是不是一个深层次的对象,用来逐个clone


Expand All @@ -50,4 +51,4 @@

</script>
</body>
</html>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
<body>

<script type="text/javascript">

//缺少这个方法,但是不影响结果。
function show(data) {
$("body").append('<li>' + data + '</li>')
}

function Callbacks() {
var list = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

//接受上一个值,叠加处理
filtered.done(function(value) {
$('body').append("<li>filtered.done ( 2*5 = ) 10: " + "</li>");
$('body').append("<li>filtered.done 2*5 = : " + value +"</li>");
});

};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
fontSize : "3em",
borderWidth : "10px",
}, 1000, function() {
show('2.动画执行结束束,对象长度'+ block.css('width'))
show('2.动画执行结束,对象长度'+ block.css('width'))
});
show('3.动画流程代码结束,对象长度'+ block.css('width'))
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@


<script type="text/javascript">
有童鞋留言到,为什么要传递undefined?
// 有童鞋留言到,为什么要传递undefined?

Javascript 中的 undefined 并不是作为关键字,因此可以允许用户对其赋值。
// Javascript 中的 undefined 并不是作为关键字,因此可以允许用户对其赋值。


我们看一个
// 我们看一个

var undefined = '慕课网'
;(function(window) {
alert(undefined);//IE8 '慕课网'

})(window)
IE8存在这个问题,当然,大部分浏览器都是不能被修改的
// IE8存在这个问题,当然,大部分浏览器都是不能被修改的


//如果函数调用不传递,参数默认就是undefined
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
a.wrap('<div class="new" />');


// 报错,empty/remove is not defined
$('#test1').click(function() {
var elem = document.querySelectorAll('.empty')
empty.call(elem)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,23 +69,16 @@
}


function empty() {
var elem,
i = 0;
for (;
(elem = this[i]) != null; i++) {
if (elem.nodeType === 1) {
elem.textContent = "";
function setText(value){
// 分数组和元素两种情况
// 元素
if(this.nodeType ===1){
this.textContent = value
} else {
for (var i = 0; i < this.length; i++) {
this[i].textContent = value
}
}
return this;
}

function setText(value) {
empty.call(this)
if (this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9) {
this.textContent = value;
}
}


Expand Down Expand Up @@ -116,6 +109,7 @@

$('#test4').click(function() {
var p = document.querySelectorAll("p")[0]
// var p = document.querySelectorAll("p")
text.call(p,'慕课网')
})

Expand Down