我试图让一个#用于scrollTop函数,但我得到的是'undefined' 我哪里出错了?试图得到一个元素的位置,但它总是'undefined'
<html><head><meta http-equiv=Content-Type content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.1/jquery.mobile-1.4.1.min.css">
<script src="http://code.jquery.com/jquery-2.1.0.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.1/jquery.mobile-1.4.1.min.js"></script>
</head><body>
<div data-role="page" id="page5" data-theme="c">
<BR><BR><BR><BR>
<p><span id="1.11.13">1.11.13</span> Lots of text here... </p>
<script>
$(window).on('pageinit', function() {
console.log($('#1.11.13').css('top')); //undefined
console.log($('#1.11.13').position()); // undefined
//console.log($('#1.11.13').offset().top); = Uncaught TypeError: Cannot read property 'top' of undefined
});
</script></div></body></html>
'$(文件)。在( 'pageinit''不是'$(窗口)。在(' pageinit''。 – Omar