JavaScript / jQuery 관해서 궁금증 채택완료
sinbi
2년 전
조회 2,261
https://codepen.io/sinbi/pen/PoBYYwY
위 링크에서는 1~300까지 잘 생성되는데,
https://codepen.io/sinbi/pen/poKMMoM
위 링크에서는 1만 생성됩니다.
(정확히 말하자면, 생성은 되는데 페이징 jQuery 소스 탓에 1만 보이게 됩니다.)
1~300까지 잘 보이게 처리하려면 어떻게 해야 할까요?
PHP로 생성하면 쉬운데, 코드펜에서 구현된 코드를 보여주고 싶어 그렇습니다.
댓글을 작성하려면 로그인이 필요합니다.
답변 1개
채택된 답변
+20 포인트
2년 전
</p>
<p>var txt = '';
for(var i = 1 ; i <= 300 ; i++) {
txt += i + "
";
}
box.innerHTML = txt;</p>
<p>$(".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" rel="nofollow noreferrer noopener" target="_blank">https://open.kakao.com/o/gzNuQjhe
로그인 후 평가할 수 있습니다
답변에 대한 댓글 1개
s
sinbi
2년 전
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인
위 코드를 제거하면 보이긴 하지만, 이전/다음 클릭 시 페이지 이동이 안 됩니다.
PS. childrent() 대신 contents()로 처리하니 되네요.