Web Development with jQuery®

(Elliott) #1

(^526) ❘ APPENDIX E MANIPULATING CONTENT, ATTRIBUTES, AND CUSTOM DATA
bapp05.indd 02/17/2015 Page 526
val(valuesArray) When providing multiple values, this method
checks or selects radio buttons, check
boxes, or select options that match the set
of values.
jQuery
val(function()) If a function is provided, it returns the con-
tent to set as the value for each selected
element.
As with most jQuery callback functions,
this refers to the current element within
the callback function, and the callback
function is provided the argument list:
offset, oldValue.
jQuery
CUSTOM DATA ATTRIBUTES
data() Returns all custom data attributes set on the
selected element(s) as a simple object.
Object
data(object) Sets custom data on all selected elements,
where the key portion is used to name the
data, and the corresponding value sets the
value of that attribute.
jQuery
data(key) Returns data stored for an element by the
specifi ed name for the selected elements.
Mixed
data(key, value) Stores data with the specifi ed name and
value for each selected element(s).
jQuery
$.data(element, key,
value)
Associates data by the specifi ed name with
the specifi ed value with the specifi ed DOM
element object reference.
Object
removeData([name]) Removes the data by the specifi ed name
from the selected elements. If no name is
specifi ed then all data is removed.
jQuery
removeData([list]) Removes data by specifying an array of data
names to remove, or a space-separated list
of data names to remove. If no list is pro-
vided, all data is removed.
jQuery
$.removeData(element[,
name])
Removes data from the specifi ed DOM ele-
ment object reference going by the speci-
fi ed name.
jQuery
(continued)
http://www.it-ebooks.info

Free download pdf