What are jQuery angle bracket selector looking things, like $('<img/>')?

jquery, jquery-selectors

Solution

The jQuery function is overloaded to construct new jQuery elements when passed a string that looks like HTML. From the docs:

If a string is passed as the parameter to $(), jQuery examines the string to see if it looks like HTML (i.e., it starts with `<tag ... >`). 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.

Problem

Sometimes I see constructs like `$('<img/>')`. How is `$('<img/>')` different from `$('img')` and where can I read more about this? I tried looking at jQuery Selectors but found nothing related to this format.

Original source

Related problems