What is the unit of measure that returns width and height in a jquery image?

1

I'm working with obtaining the height and width of an image size

I start from an image that I know what its sizes are

width 2160px
high 3840px

My code in javacript

//Quitamos el ancho y  alto que tiene en el navegador para obtener el tamaño original
 $('#imagen').removeAttr("width"); 
$('#imagen').removeAttr("height");
alert('ancho'+$('#imagen').width()+'X alto'+$('#imagen').height());

return the following


ask what is the unit of measure that returns?

    
asked by harriroot 06.12.2016 в 21:16
source

1 answer

2

In the jQuery documentation for .height() (and in parallel for .width() ) it is specified that the returned values are in pixels but without unit (bold put by me to highlight):

  

The difference between .css( "height" ) and .height() is that the last returns to unit-less pixel value (for example, 400 ) while the former returns to value with units intact (for example, 400px ). The .height() method is recommended when an element's height needs to be used in a mathematical calculation.

What can be translated as:

  

The difference between .css( "height" ) and .height() is that the latter returns as a value pixels without units (for example, 400 ) while the first one returns the value with units intact (for example, 400px ). The use of .height() is recommended when the height of the element is needed to perform mathematical calculations.

    
answered by 06.12.2016 / 21:35
source