Question for J-Query Scroll Event.

Asked 2 years ago, Updated 2 years ago, 32 views

<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<!DOCTYPE HTML>
<html lang="ko">
<!--ie Conditional Comment //-->
<!--[if lt IE 7]>      <html class="ie6"> <![endif]-->
<!--[if IE 7]>         <html class="ie7"> <![endif]-->
<!--[if IE 8]>         <html class="ie8"> <![endif]-->
<!--[if gt IE 8]><!-->          <!--<![endif]-->
<head>
<title></title>

<c:import url="/src/user/jsp/meta.jsp" charEncoding="UTF-8" />

<link rel="stylesheet" href="/src/user/css/import.css" type="text/css" />
<script  src="http://code.jquery.com/jquery-latest.min.js"></script>
<script  src="/src/user/js/default.js"></script>

</head>

<body >

<script type="text/javascript">
    $(document).ready(function(){



        console.log("$(document).height()  : " , $(document).height());
        console.log("$(body).height() : " , $("body").height())
    });


    //This is it.
    $(window).scroll(function(){
        console.log("ss")
    });

</script>

<div id="wrap_wide" >


</div><!-- END wrap//-->
</body>
</html>

I'm going to do infinite scrolling paging

When you select the $(body) selector, the scroll event is applied

Window objects are

No scroll events occur.

I don't know why. Help me

(There are no error messages in the console window.)

In addition, when the body selector is set, scrollTop returns 0 and a half.

jquery javascript

2022-09-22 15:33

1 Answers

Isn't it because there's no body, so scrolls aren't fresh? I didn't scroll through the code you uploaded, but I opened the Chrome developer tool console on this page

$(window).scroll(function(){
        console.log("ss")
    });

If you do this, the log is good.


2022-09-22 15:33

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.