.load()只能請求一次嗎?不能反復(fù)?執(zhí)行一次后,第二次請求不出來
? ? ? ??
? ? ? ? <script type="text/javascript">
? ? ? ? ? ? $(function () {
? ? ? ? ? ? ? ? $("#btnShow").bind("click", function () {
? ? ? ? ? var $this=$(this);
? ? ? ? ? if($this.val()=="加載"){
? ? ? ? ? ? ? ? ? ? $("ul")
? ? ? ? ? ? ? ? ? ? .html("<img src='Images/Loading.gif' alt=''/>")
? ? ? ? ? ? ? ? ? ? ?.load("http://idcbgp.cn/data/fruit_part.html",function(){
? ? ? ? ? ? ? ? ? ? ? ? $this.val("收起");
? ? ? ? ? ? ? ? ? ? })}else{
? ? ? ? ? ? ? ? ? ? ? ? $("ul").hide(1000);
? ? ? ? ? ? ? ? ? ? ? ? $this.val("加載");
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? })
? ? ? ? ? ? ? ? ? ??
? ? ? ? ? ? });
? ? ? ? </script>
2016-05-11
.load()不是只能加載一次,你的代碼只能加載一次的原因是else{
?$("ul").hide(1000);
},你的else代碼是將ul標簽隱藏了,而不是清空.如果要實現(xiàn)多次加載,代碼
else{$("ul").html("")}
或者只是隱藏/顯示替換 else內(nèi)容不變,if里面加一個
$("ul").show() 即可