的index.php
<html>
<head>
<script type="text/javascript" src="jquerys/jquery.js"></script>
<style>
#parentcontainer div
{
height:900px;
width:600px;
clear:both;
border:1px solid red;
padding:10px;
margin:50px 0px;
}
</style>
<script>
function showHint()
{
$('div').load('getdivs.php');
$(window).scroll(function()
{
$( ':visible' ).filter('.same').each(function()
{
alert($(this).attr('id'));
});
});
}
</script>
</head>
<body onload="showHint()">
<p>Suggestions: <div class="same2" id="parentcontainer"></div></p>
</body>
</html>
getdivs.php
<div class="same" id="childcontainer1"> content here
</div>
<div class="same" id="childcontainer2"> content here
</div>
当我向下滚动窗口时,无论我在窗口中查看的div
如何,我都会收到所有div
与(.same)类的提醒。我想要在滚动页面上显示的DIV&S对应的ID。