JavaScript / jQuery 관해서 궁금증

JavaScript / jQuery 관해서 궁금증

QA

JavaScript / jQuery 관해서 궁금증

본문

https://codepen.io/sinbi/pen/PoBYYwY

위 링크에서는 1~300까지 잘 생성되는데,

 

https://codepen.io/sinbi/pen/poKMMoM

위 링크에서는 1만 생성됩니다.

(정확히 말하자면, 생성은 되는데 페이징 jQuery 소스 탓에 1만 보이게 됩니다.)

 

1~300까지 잘 보이게 처리하려면 어떻게 해야 할까요?

PHP로 생성하면 쉬운데, 코드펜에서 구현된 코드를 보여주고 싶어 그렇습니다.

이 질문에 댓글 쓰기 :

답변 1


var txt = '';
for(var i = 1 ; i <= 300 ; i++) {
    txt += i + "<br>"; 
}
box.innerHTML = txt;
$(".next").click(function () {
  var current = $(".content").css("margin-top") || "0px";
  if (parseInt(current.substring(0, current.length - 2)) >=
    $(".content").height() * -1 + $(".box").height()) {
    $(".content").css(
      "margin-top", current.substring(0, current.length - 2) -
        $(".box").height() + "px"
    );
  }
});
$(".prev").click(function () {
  var current = $(".content").css("margin-top") || "0px";
  if (parseInt(current.substring(0, current.length - 2)) != 0) {
    $(".content").css(
      "margin-top", parseInt(current.substring(0, current.length - 2)) + $(".box").height() + "px"
    );
  }
});

 

 

--------------------------------------------------------------------------------------------------------------------

 

더 자세한 내용이 궁금하시면 여기 방문하세요

같이 얘기나누며 문제해결에 도움이 되도록 하세요

 

https://open.kakao.com/o/gzNuQjhe

$(".box").children().wrapAll('<div class="content"/>');
위 코드를 제거하면 보이긴 하지만, 이전/다음 클릭 시 페이지 이동이 안 됩니다.

PS. childrent() 대신 contents()로 처리하니 되네요.

답변을 작성하시기 전에 로그인 해주세요.
전체 1,012
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT