Skip to main content

Bug Tracker

Side navigation

#10994 closed enhancement (duplicate)

Opened December 10, 2011 01:17PM UTC

Closed December 10, 2011 02:11PM UTC

Last modified December 10, 2011 02:12PM UTC

Extend the functionality of outherWidth to be able to set the objects width

Reported by: contact@andresbott.com Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.7.1
Keywords: Cc:
Blocked by: Blocking:
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;
	}
});
Attachments (0)
Change History (2)

Changed December 10, 2011 02:11PM UTC by dmethvin comment:1

resolution: → duplicate
status: newclosed

Changed December 10, 2011 02:12PM UTC by dmethvin comment:2

Duplicate of #10877.