Write a jQuery code to find absolute position of an element.
Answer :
File Name : jQuery.html
<html>
<head>
<script src="https://code.jquery.com/jquery-3.6.0.js" integrity="sha256-H+K7U5CnXl1h5ywQfKtSj8PCmoN9aaq30gDh27Xc0jk=" crossorigin="anonymous"></script>
<title>SP Creation</title>
</head>
<body>
<div class="container">
<h2>jquery</h2>
<div class="col" id="info">
<h3>INFO</h3>
<p>Lorem ipsum dolor sit amet consectetur, adipisicing elit. Voluptas, magni.</p>
<p id="pos"></p>
</div>
</div>
<script>
$(document).ready(function(){
var a = ($('#info').position());
$('#pos').html("Top : " + a.top + " Left : " + a.left);
});
</script>
</body>
</html>
Write a jQuery code to find absolute position of an element.
Reviewed by technical_saurabh
on
May 03, 2021
Rating:
No comments:
Post a Comment