1.

What Is The Difference Between Methods - “css(‘width’)” And “width()” In Jquery?

Answer»

Both methods are used to change the widths of the elements.

For EXAMPLE:

$(‘#myControlID’).css(‘WIDTH’,’150px’);

$(‘#myControlID’).width(150);

Above is the code to change the width of the element to 150px. As you can SEE “css(width)” method takes the width in pixels whereas for “width” method no NEED to EXPLICITLY mention the width in pixels.

Both methods are used to change the widths of the elements.

For example:

$(‘#myControlID’).css(‘width’,’150px’);

$(‘#myControlID’).width(150);

Above is the code to change the width of the element to 150px. As you can see “css(width)” method takes the width in pixels whereas for “width” method no need to explicitly mention the width in pixels.



Discussion

No Comment Found