/ Published in: jQuery
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<!DOCTYPE html> <html> <head> <script src="http://code.jquery.com/jquery-git.js"></script> <script> $(window).resize(function() { $("#test").text($(document).width() + " x " + $(document).height()); }); </script> </head> <body> <button id="getp">Get Paragraph Height</button> <button id="getd">Get Document Height</button> <button id="getw">Get Window Height</button> <div> </div> <p> Resize window </p> <script> function showHeight(ele, h) { $("div").text("The height for the " + ele + " is " + h + "px."); } $("#getp").click(function () { showHeight("paragraph", $("p").height()); }); $("#getd").click(function () { showHeight("document", $(document).height()); }); $("#getw").click(function () { showHeight("window", $(window).height()); }); </script> <div id="test"></div> </body> </html>