2014-12-28 2 views
-1

"more load ..."링크에 nice solution here이 있습니다.이 예제에서 "more more div"버튼을 변경하는 방법

참조 된 대답에는 JSFidlle example이 있습니다. 어떻게 숨겨진 div가 남아 있지 않으면 "더 많은 div"로 "더로드"텍스트를 변경할 수 있습니까? 현재 경고가 있지만 '더로드하기'라는 텍스트를 'No divs'로 변경하는 것을 선호합니다.

순간에 내 코드 : 당신이 요청으로 링크가 단순히 아래의 코드를 사용하여이 "더 이상 된 div"로 변경되지 않습니다

$(function(){ 
    $("div").slice(0, 10).show(); // select the first ten 
    $("#load").click(function(e){ // click event for load more 
     e.preventDefault(); 
     $("div:hidden").slice(0, 10).show(); // select next 10 hidden divs and show them 
     if($("div:hidden").length == 0){ // check if any hidden divs still exist 
      alert("No more divs"); // alert if there are none left 
     } 
    }); 
}); 

답변

2

: 내 친구 바위

$(function(){ 
    $("div").slice(0, 10).show(); // select the first ten 
    $("#load").click(function(e){ // click event for load more 
     e.preventDefault(); 
     $("div:hidden").slice(0, 10).show(); // select next 10 hidden divs and show them 
     if($("div:hidden").length == 0){ // check if any hidden divs still exist 
      $("#load").text("No more divs"); // change the text of the link to "No more divs" 
     } 
    }); 
}); 
+0

을 – kodjoe

+0

그냥 질문의 선생님, 클릭 할 수있는 링크가 없으면 "더 이상 div가 없습니까?" – kodjoe