Web Development with jQuery®

(Elliott) #1

(^524) ❘ APPENDIX E MANIPULATING CONTENT, ATTRIBUTES, AND CUSTOM DATA
bapp05.indd 02/17/2015 Page 524
removeAttr(name) Removes the specifi ed attribute from the
element(s).
jQuery
CLASS NAMES
addClass(className) Adds the specifi ed class name to each
selected element. Elements can have one or
more class names.
jQuery
addClass(function()) Adds one or more space separated class
names returned from a callback function.
jQuery
hasClass(className) Returns true if the specifi ed class name
is present on at least one of the selected
elements.
Boolean
removeClass([className]) Removes the specifi ed class name from each
selected element. If multiple class names
are provided, each is separated by a single
space.
jQuery
removeClass(function()) Removes the specifi ed class name from
each selected element by executing a
callback function to determine whether
the class should be removed. The function
should return one or more class names to
be removed. If multiple class names are
removed, they should be separated by a
single space.
jQuery
toggleClass(className[,
switch])
Adds the specifi ed class name if it is not
present, and removes the specifi ed class
name if it is present.
If the switch argument is provided, it explic-
itly tells toggleClass() whether the class
name should be added or removed. true
adds the class, and false removes it.
jQuery
toggleClass([switch]) switch explicitly tells toggleClass()
whether the class name should be added or
removed. true adds the class, and false
removes it.
jQuery
toggleClass(function()[,
switch])
If a function is provided, it returns one or
more space separated class names to be
toggled.
If the switch argument is provided, it
explicitly tells toggleClass() whether the
class name should be added or removed.
true adds the class, and false removes it.
jQuery
(continued)
http://www.it-ebooks.info

Free download pdf