Web Development with jQuery®

(Elliott) #1

(^544) ❘ APPENDIX H CSS
bapp08.indd 02/19/2015 Page 544
removeClass(className) Removes the class name(s) from the selected
element(s). Multiple class names are separated
by spaces.
jQuery
toggleClass(className) Adds or removes one or more class names from
the selected elements. Multiple class names are
separated by spaces.
jQuery
POSITIONING
offset() Returns the offset position of the fi rst selected
element relative to the viewport—for example:
var offset = $('div').offset();
alert('Left: ' + offset.left);
alert('Top: ' + offset.top);
Object
position() Gets the coordinates of the element relative to
the offset parent—for example:
var position = $('div').position();
alert('Left: ' + position.left);
alert('Top: ' + position.top);
Object
HEIGHT AND WIDTH
height() Returns the pixel height (CSS height, exclud-
ing borders and padding) of the fi rst selected
element.
Integer
height(value) Sets the height (CSS height) of the fi rst selected
element. If no unit of measurement is provided,
px (pixels) is used.
jQuery
innerHeight() Gets the inner height of the element, including
padding, but not the border.
Integer
innerWidth() Gets the inner width of the element, including
padding, but not the border.
Integer
width() Returns the pixel width (CSS width, exclud-
ing borders and padding) of the fi rst selected
element.
Integer
width(value) Sets the width (CSS width) of the fi rst selected
element. If no unit of measurement is provided,
px (pixels) is used.
jQuery
(continued)
http://www.it-ebooks.info

Free download pdf