0
Why is $("<p></p>").text ("example") used in place of $("p")?
I have been learning JQuery with the app but it never really explains any difference or use for that
3 Respuestas
+ 2
the first selects all p tags,same with second.But the difference is the first can be used to select a p tag with I'd
$("<p Id='p' ></p>");
0
I am not quite sure, but does the first selector select empty paragraphs, while the second selects all paragraphs, doesn't it?
UPDATE: first selector and second are totally equal. My first suggestion is wrong that would be done by
$("p:empty"). This means you can use both in the same way. For class or id selection use their specific selectors.
0
Therefore you should use the ID selector $("#id)