Content API
inTxt()
Sets or gets the text content of the matched DOM elements and their descendants.
- Accepts an argument as a string.
- Can read styles and retrieve CSS, but does not return the contents of hidden elements or the contents of "<script>" and "<style>" tags.
- If no arguments are passed, it returns a string if a single matched DOM element, and an array of strings if multiple matched DOM elements.
Example:
$('div').inTxt('');
$('div').inTxt(null);
// Removes the text content from the <div> element.
$('div ?').inTxt('');
$('div ?').inTxt(null);
// Removes the text content from all <div> elements.
$('div ?').inTxt('cat');
// <div>cat</div>
// <div>cat</div>
// <div>cat</div>
$('div').inTxt('book');
// <div>book</div>
// <div>cat</div>
// <div>cat</div>
$('div').inTxt();
// 'book'
$('div ?').inTxt();
// ['book', 'cat', 'cat']