Get the HTML contents of the first element in the set of matched elements or set the HTML contents of every matched element.
// <div class="content"><span>Hi</span></div>
const content = $('.content').html();
"<span>Hi</span>"
$('.content').html('<strong>New Content</strong>');
<div class="content">
<strong>New Content</strong>
</div>
$('div').html((index) => `<span>Item ${index}</span>`);
<div><span>Item 0</span></div>
<div><span>Item 1</span></div>
| Parameter | Type | Description |
|---|---|---|
| content | string | function | The HTML string to set, or a function that returns an HTML string. Function receives (index, currentHtml). |
Returns: The innerHTML string for getter, or the original SR object for setter.