jQuery outerWidth Method


jQuery outerWidth Method : is used to get the width of selected element including the padding and border both. It returns width padding and border ie. outer width = border width + padding + with of container.
We are going to explain this method with example and demo.


jQuery outerWidth Method Syntax

jQuery Syntax for outer with –

$(selector).outerWidth();

jQuery outerWidth Method Example

Here is example for outer with of the container –

<script type="text/javascript">
         $(document).ready(function(){ 
              $( "#widthExample" ).on( "click", function(event) {             
                  var x = $("#myDiv").outerWidth();       
                          $("#myDiv > p").html("Outer Width = "+x+"px");     
              });
               
          });
</script>

Try it »

If you run the above example it will produce the following output-

jQuery outerWidth Method


Advertisements

Add Comment

📖 Read More