Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Managing Content

Content is king

A few words about element content — we have 2 methods for working with it: html() and text(). There's one key difference between them — the first one can get and insert HTML code, while the second always operates with text. Even if you try to feed it HTML, you'll get text where the tags are converted to HTML entities:

$("section").text("Some <strong>text</strong>");

<section>Some &lt;strong&gt;text&lt;/strong&gt;</section>

returns the HTML of the given element

replaces the HTML in the given element

returns the text of the given element; if there are other HTML tags inside the element, you'll get a mixed bag of text from all elements

replaces the text inside the selected elements; if you try to insert HTML this way, you'll still get text

Last updated