SetTimeOut這個Function在這里做為異步函數(shù),基本流程通俗來說如下:
調(diào)用函數(shù)A -> 執(zhí)行setTimeout -> 函數(shù)A結(jié)束 -> 大致500ms后異步觸發(fā)函數(shù)B -> 執(zhí)行setTimeout -> 函數(shù)B結(jié)束 -> 大致1000ms后觸發(fā)匿名function(data2) {$(".container").html("嵌套異步:" + data2)}
在各個位置加入alert函數(shù),你會看的很清楚
調(diào)用函數(shù)A -> 執(zhí)行setTimeout -> 函數(shù)A結(jié)束 -> 大致500ms后異步觸發(fā)函數(shù)B -> 執(zhí)行setTimeout -> 函數(shù)B結(jié)束 -> 大致1000ms后觸發(fā)匿名function(data2) {$(".container").html("嵌套異步:" + data2)}
在各個位置加入alert函數(shù),你會看的很清楚
2017-12-31
點擊按鈕沒反應 是 JS 加載的問題, 用下面的源替換代碼中的源
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="https://ricostacruz.com/jquery.transit/jquery.transit.js"></script>
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="https://ricostacruz.com/jquery.transit/jquery.transit.js"></script>
2017-12-31
為什么開始要寫var slice = Array.prototype.slice這個,這和使用有原生的slice,有什么區(qū)別?
function toArray(a, i, j) {
return slice.call(a, i || 0, j || a.length);
}
還有這個函數(shù)的作用是什么?生成指定位置之間的數(shù)組?
function toArray(a, i, j) {
return slice.call(a, i || 0, j || a.length);
}
還有這個函數(shù)的作用是什么?生成指定位置之間的數(shù)組?
2017-12-29
已采納回答 / FloatingShuYin
??? ? ? ? ? ? //起立? ? ? ? ? ? setTimeout(function(){? ? ? ? ? ? ? ? $girl.addClass("girl-standUp");? ? ? ? ? ? },200)? ? ? ? ? ? //拋書? ? ? ? ? ? setTimeout(function(){? ? ? ? ? ? ? ? $girl.addClass(...
2017-12-29
聲明了兩個next方法
pageA.prototype.next = function(options) {}
和
var next = function() {
return this.next.apply(this, arguments)
}.bind(this)
這會讓 新手頭暈的.
pageA.prototype.next = function(options) {}
和
var next = function() {
return this.next.apply(this, arguments)
}.bind(this)
這會讓 新手頭暈的.
http://www.ruanyifeng.com/blog/2011/08/a_detailed_explanation_of_jquery_deferred_object.html