Web Development with jQuery®

(Elliott) #1

Appendix E (^) ❘ 525
bapp05.indd 02/17/2015 Page 525
HTML
html() Returns the HTML contents, or innerHTML,
of the fi rst element of the selection. This
method does not work on XML documents
but does work on XHTML documents.
String
html(htmlString) Sets the HTML contents of every selected
element.
jQuery
html(function()) If a function is provided, it returns the HTML
content to set 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, oldHTML.
jQuery
TEXT
text() Returns the text content of each selected
element.
String
text(value) Sets the text content of each selected
element. HTML source code will not be
rendered.
jQuery
text(function()) If a function is provided, it returns the text
content to set 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, oldText.
jQuery
VALUE
val() Returns the contents of the value attri-
bute for the fi rst element of the selection.
For