Bug Tracker

Ticket #10994 (closed enhancement: duplicate)

Opened 3 years ago

Last modified 3 years ago

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

comment:1 Changed 3 years ago by dmethvin

  • Status changed from new to closed
  • Resolution set to duplicate

comment:2 Changed 3 years ago by dmethvin

Duplicate of #10877.

Note: See TracTickets for help on using tickets.