jQuery width Method : is used to get or set the width of selected element. If want to set width of element pass width in .width() as input parameter.
We are going to explain jquery width method with example and demo.
jQuery width Method Syntax 1 Get Width
In this example we will get width of element using .width() method.
$(selector).width();
jQuery width() Method Example 1
Below example shows the get width method functionality –
jQuery width Method Syntax 2 – Set Width
If you want to add width dynamically you can use width method as below-
$(selector).width(width);
width(px): Width in pixel.
jQuery width() Method Example 2
Here is an example of set width method –