Categories

.innerWidth()

Categories: Style Properties | CSS | Dimensions

.innerWidth()Returns: Integer

Description: Get the current computed width for the first element in the set of matched elements, including padding but not border.

  • .innerWidth()

    version added: 1.0

This method returns the width of the element, including left and right padding, in pixels.

This method is not applicable to window and document objects; for these, use .width() instead.

  • Get the innerWidth of a paragraph.

    HTML:
    <p>Hello</p><p></p>
    CSS:
    p { margin:10px;padding:5px;border:2px solid #666; } 
    Code:
    var p = $("p:first");
    $("p:last").text( "innerWidth:" + p.innerWidth() );

.innerWidth( value )Returns: jQuery

Plugin: jQuery.fn.size

Description: Set the current computed width for each element in the set of matched elements, including padding but not border.

  • .innerWidth( value )

    version added: 1.0

    value   An integer representing the number of pixels.

This method set the width of the element, including left and right padding, in pixels.

This method is not applicable to window and document objects.

  • Set the inner width of all div elements with class box.

    HTML:
    <div class="box"></div>
    CSS:
    .box {
        position:    absolute,
        margin:      15px,
        border:      solid 5px,
        padding:     10px,
        width:       100px,
        height:      100px
    }
    Code:
    $('div').innerWidth(300);
    Results:
    <div class="box" style="width: 280px;"></div>