.html()和.load()是怎樣一個(gè)執(zhí)行過程?.load()為什么會(huì)把.html()里面的內(nèi)容覆蓋掉?
<script?type="text/javascript"> ????????????$(function?()?{ ????????????????$("#btnShow").bind("click",?function?()?{ ????????????????????var?$this?=?$(this); ????????????????????$("ul") ????????????????????.html("<img?src='Images/Loading.gif'?alt=''/>") ????????????????????.load("http://idcbgp.cn/data/fruit_part.html",function(){ ????????????????????????$this.attr("disabled",?"true"); ????????????????????}); ????????????????}) ????????????}); ????????</script>
2016-03-24
首先你的html()方法在load()方法之前執(zhí)行,所以load()會(huì)覆蓋掉,其次load和html的區(qū)別:load可以加載遠(yuǎn)程資源,而html是改變所匹配的 HTML 元素的內(nèi)容(類似innerHTML)。