Content API
num()
Sets or gets the numeric content of the matched DOM elements and their descendants.
- Accepts an argument as a string or a number.
- Cannot read styles or retrieve CSS, returns the contents of hidden elements and the contents of "<script>" and "<style>" tags.
-
If no arguments are passed, it returns a number for a single matched DOM element or an array of numbers for multiple matched DOM elements.
If the value cannot be parsed as a number, NaN will be returned.
Example:
$('div ?').num(10);
// <div>10</div>
// <div>10</div>
// <div>10</div>
$('div').num(10);
// <div>10</div>
// <div>The content is unchanged.</div>
// <div>The content is unchanged.</div>
$('div').num();
// 10
$('div ?').num();
// [10, NaN, NaN]