Modify ↓
Ticket #10994 (closed enhancement: duplicate)
Extend the functionality of outherWidth to be able to set the objects width
| Reported by: | contact@… | Owned by: | |
|---|---|---|---|
| Priority: | undecided | Milestone: | None |
| Component: | unfiled | Version: | 1.7.1 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
i'm writing here because there are some situations where you need to set the width/height of an object to fit a specific size.
if you use the width/height function the object will have width+paddin+border+margin
for my personal use i made a function to set the width, according to the defined padding and border, and i think this should be also implemented in the core outherWidht function
my fucntion:
$.fn.extend({
setOuterWidth: function($value){
var elemento = $(this);
var bordes = 0;
bordes = bordes + parseInt( elemento.css('margin-left'));
bordes = bordes + parseInt( elemento.css('margin-right'));
bordes = bordes + parseInt( elemento.css('border-left-width'));
bordes = bordes + parseInt( elemento.css('padding-left'));
bordes = bordes + parseInt( elemento.css('padding-right'));
bordes = bordes + parseInt( elemento.css('border-right-width'));
$(this).css( 'width' , ( parseInt($value) - bordes) );
return this;
}
});
Change History
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.
Note: See
TracTickets for help on using
tickets.
