Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>From the <a href="http://api.jquery.com/jQuery/" rel="noreferrer">docs</a>:</strong></p> <blockquote> <p>If a string is passed as the parameter to $(), jQuery examines the string to see if it looks like HTML (i.e., it has <code>&lt;tag ... &gt;</code> somewhere within the string). If not, the string is interpreted as a selector expression, as explained above. But if the string appears to be an HTML snippet, jQuery attempts to create new DOM elements as described by the HTML. Then a jQuery object is created and returned that refers to these elements. You can perform any of the usual jQuery methods on this object:</p> </blockquote> <pre><code>$('&lt;p id="test"&gt;My &lt;em&gt;new&lt;/em&gt; text&lt;/p&gt;').appendTo('body'); </code></pre> <blockquote> <p>If the HTML is more complex than a single tag without attributes, as it is in the above example, the actual creation of the elements is handled by the browser's innerHTML mechanism. In most cases, jQuery creates a new element and sets the innerHTML property of the element to the HTML snippet that was passed in. When the parameter has a single tag, such as <code>$('&lt;img /&gt;') or $('&lt;a&gt;&lt;/a&gt;')</code>, jQuery creates the element using the native JavaScript createElement() function.</p> </blockquote> <p><strong>To ensure cross-platform compatibility, the snippet must be well-formed. Tags that can contain other elements should be paired with a closing tag</strong>:</p> <pre><code>$('&lt;a href="http://jquery.com"&gt;&lt;/a&gt;'); </code></pre> <p>Alternatively, jQuery allows XML-like tag syntax (with or without a space before the slash):</p> <pre><code>$('&lt;a/&gt;'); </code></pre> <p>Tags that cannot contain elements may be quick-closed or not:</p> <pre><code>$('&lt;img /&gt;'); $('&lt;input&gt;'); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload