Tutorials Point


  Learn Prototype
  Prototype Resources
  Selected Reading

Copyright © 2014 by tutorialspoint



  Home     References     Discussion Forums     About TP  

Prototype clonePostion() Method


previous next AddThis Social Bookmark Button


Advertisements

This method clones the position and/or dimensions of source onto element as defined by the optional argument options.

Syntax:

element.clonePosition(source[, options]);

Here is the list of possible options:

NameDefaultDescription
setLefttrueclones source's left CSS property onto element.
setToptrueclones source's top CSS property onto element.
setWidthtrueclones source's width onto element.
setHeighttrueclones source's width onto element.
offsetLeft0Number by which to offset element's left CSS property.
offsetTop0Number by which to offset element's top CSS property.

Return Value:

  • An HTML element.

Example:

<html>
<head>
<title>Prototype examples</title>
<script type="text/javascript" 
   src="/javascript/prototype.js">
</script>
<script>


function clonePosition(){
   var firstElement = $('firstDiv');
   var secondElement = $('secondDiv');
   secondElement.clonePosition( firstElement);
}

</script>
</head>

<body>

   <p>Click Clone Position button to see the result.</p>
   <div id="firstDiv">
      <p>This is first paragraph</p> 
   </div>

   <div id="secondDiv">
      <p>This is second paragraph</p> 
   </div>

   <br />
   <input type="button" value="Clone Position" 
             onclick="clonePosition();"/>

</body>
</html>

To understand it in better way you can Try it yourself.



previous next Printer Friendly

Advertisements


  

Advertisements