jQuery Tutorial
jQuery width() Method With Syntax and Example
Understanding width method in jQuery
The width()
method determines or returns the width of the elements that have been selected.
This method returns the width of the FIRST matched element when used to replace width. This method sets the width of ALL matched elements when used to set the width.
Padding, border, or margin is not included.
Syntax of width method in jQuery
$(selector).toggleClass(classname,function(index,currentclass),switch)
Example of jQuery width method
Return the width of a
element:
$("button").click(function(){
alert($("div").width());
});