0 votes
in JQuery by
What is the difference between width() vs css(‘width’) in jQuery?

1 Answer

0 votes
by

CSS(‘width’) returns the width value in pixels, whereas width() returns the integer (without the unit values). For example:

div{

width: 20cm;

}

If you print the values:

$(this).width();

$(this).css(‘width’);

you will get the values like 756 and 756px, respectively. Note that though we specified width in cm, it is converted to pixel (px) for output purposes.

...