JavaScript Programming
JavaScript > Code Examples
Access the offset of the second paragraph
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
Access the offset of the second paragraph
<html>
<head>
<title>Happy Codings :-) JavaScript Code Examples</title>
<script type="text/javascript" src="js/jquery-1.3.2.js"></script>
<script type="text/javascript">
$(document).ready(function(){
var p = $("p:last");
var offset = p.offset();
p.html( "left: " + offset.left + ", top: " + offset.top );
});
</script>
</head>
<body>
<p>Hello</p><p>2nd Paragraph</p>
<p>
Happy Codings :-) JavaScript Code Examples
<br>
</p>
</body>
</html>