Outerwidth Code - Jquery

How to get outer width using jquery code?

Snippet Code


  
Rate this page :
  [ 0 votes]

Get the outer width of the entire element, including padding and border using outerWidth() function.

<script type="text/javascript"> $(document).ready(function() { $("div").click(function () { var width = $(this).outerWidth( true ); $("#output").html("Outer Width <span>" + width + "</span>."); }); }); </script> <style> .div1{ margin:10px;padding:12px; border:2px solid grey;border-radius:5px; width:80px;} .div2 { margin:15px;padding:5px; border:3px solid grey;border-radius:3px; width:160px;} </style> <p><b>Click on any div:</b></p> <span id="output"> </span> <div class="div1">Hiox.com</div> <div class="div2">Hscripts.com</div>

Tags


Ask Questions

Ask Question