jQuery offset() set via an object literal

Introduction

Set the offset coordinates of the p element

View in separate window

<!DOCTYPE html>
<html>
<head>
<script 
 src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js">
</script>/*from   w  w w .  j  a  v a 2s .  c o  m*/
<script>
$(document).ready(function(){
  $("button").click(function(){
      $("p").offset({top: 200, left: 200});
  });
});
</script>
</head>
<body>

<p>This is a paragraph.</p>

<button>Set</button>

</body>
</html>



PreviousNext

Related