') and $('p')
Can someone explain to me the difference between \')$(\' and $(\'p\') in jQuery.
for example, if i write:
$(\'body\').
jQuery can parse HTML an create an actual DOM element. That is, when you do something like $(""), jQuery is parsing the markup and internally creating a DOM paragraph element that can be appended to the document.
In the other hand, jQuery integrates Sizzle, a CSS selector engine. The jQuery function accepts CSS selectors, meaning that $("p") is selecting all paragraph elements in the document. You can also use more complex selectors like $("p:first-child") and select the first paragraph of the document.
Learn more about jQuery CSS selectors here.