ctrl+k
Enter a search term above to see results...
Get and set form values, text content, and HTML content.
$('selector').val();$('selector').val(value);Gets or sets the value of form elements.
Alias
value()
| Name | Type | Description |
|---|---|---|
| value | any | The value to set |
const inputValue = $('input').val();$('input').val('New value');$('selector').text();$('selector').text(content);Gets or sets the text content of elements.
| Name | Type | Description |
|---|---|---|
| content | string | The text to set |
const buttonText = $('button').text();$('button').text('Click me!');$('selector').textNode();Gets the text content of immediate text node children only. Use text() when you need all nested text content recursively.
Combined text content of immediate text node children.
<p>Hello <span>world</span></p>$('p').text(); // "Hello world"$('p').textNode(); // "Hello "$('selector').html();$('selector').html(content);Gets or sets the inner HTML of elements.
| Name | Type | Description |
|---|---|---|
| content | string | The HTML to set |
const content = $('.container').html();$('.container').html('<p>New content</p>');$('selector').outerHTML();$('selector').outerHTML(content);Gets or sets the outer HTML, including the element’s own tag.
| Name | Type | Description |
|---|---|---|
| content | string | The outer HTML to set |
const markup = $('.card').outerHTML();$('.card').outerHTML('<section class="card">New</section>');Methods for working with slots in web components.
$('selector').getSlot();$('selector').getSlot(name);Gets content assigned to slots in web components.
| Name | Type | Description |
|---|---|---|
| name | string | Slot name (omit for default slot) |
Combined HTML content of elements assigned to the slot.
$(myComponent).getSlot();$(myComponent).getSlot('header');$$(myComponent).find('slot[name="header"]').getSlot();$('selector').setSlot(content);$('selector').setSlot(name, content);Sets content for slots in web components.
| Name | Type | Description |
|---|---|---|
| name | string | Slot name (omit for default slot) |
| content | string | Element | Content to assign to the slot |
Query object (for chaining).
$(myComponent).setSlot('<p>Main content</p>');$(myComponent).setSlot('header', '<h1>Title</h1>');