How to return the position of the element relative to floating objects in JavaScript?

HTMLJavascriptProgramming Scripts

To return the position of the element relative to floating objects, use the clear property in JavaScript.

Example

You can try to run the following code to learn how to return the position of the element.

Live Demo

<!DOCTYPE html>
<html>
   <head>
      <style>
         img {
            float: left;
         }
      </style>
   </head>
   <body>
      <img src="https://www.tutorialspoint.com/videotutorials/images/tutor_connect_home.jpg" width="170" height="150">
      <p id="myP">Demo content! Demo content! Demo content! Demo content! Demo content! Demo content! Demo content! Demo content! Demo content! Demo content!
         Demo content! Demo content! Demo content! Demo content! Demo content! Demo content! Demo content! Demo content! Demo content! Demo content! Demo content! Demo content! Demo content!</p>
      <button type="button" onclick="display()">Click</button>
      <script>
         function display() {
            document.getElementById("myP").style.clear = "left";
         }
      </script>
   </body>
</html>
raja
Published on 26-Feb-2018 15:56:09
Advertisements