Home
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> <style> .coral { padding: 10px; background-color: coral; } </style> <script> $(document).ready(function () { $("button").click(function () { // set height $('#mydiv').height(200); // get height var ht = $('span.coral').height(); alert("the height of span tag is " + ht); }); }); </script> </head> <body> <h1>jQuery Manipulation Methods: height()</h1> <span class="coral">This is a span tag</span> <div id="mydiv" style="background-color: aquamarine;"> <p>This is a paragraph</p> <p>This is a paragraph</p> </div> <button>Click Here to Test .height()</button> </body> </html>
Result: