Search code examples
javascriptprototypejs

Get an element's outer width in Prototype.js


Does Prototype.js have a simple way of returning an element's outer width?

ie: width + left/right padding + left/right border.

Like jQuery's .outerWidth()


Solution

  • Element.Layout can help you in this regard, Here is a full fiddle demonstrating the options

    CODE FROM FIDDLE

    var layout = $('d1').getLayout();
    console.log('My Width : ' + layout.get('width') + 'px');
    console.log('My Full Width : ' + layout.get('border-box-width') + 'px');