1.

Explain Width() Vs Css('width')?

Answer»
  • In jQuery, there are two ways to change the width of an ELEMENT.
  • One way is using .css(‘width’) and other way is using .width().
  • For example

    $(‘#mydiv’).css(‘width’,’300px’); $(‘#mydiv’).width(100);
  • The difference in .css(‘width’) and .width() is the data TYPE of value we SPECIFY or return from the both functions.
  • In .css(‘width’) we have to add “px” in the width value while in .width() we don’t have to add.
  • When you WANT to GET the width of “mydiv” element then .css(‘width’) will return ‘300px’ while .width() will return only integer value 300.

For example



Discussion

No Comment Found