I would like to select the p elements inside a particular div, #homepage. I know how to select all the #homepage, or all of the li's on the page, but how do I selected a nested group of li's?
Thank you!
I would like to select the p elements inside a particular div, #homepage. I know how to select all the #homepage, or all of the li's on the page, but how do I selected a nested group of li's?
Thank you!
$("#homepage p"); // All the `p` tags inside `div#homepage`
You need to look at the jQuery Documentation for Selectors and specifically the section titled Hierarchy.
You can nest selectors by separating them with a space.
In your case, $('#homepage p') matches all p elements that are inside (directly or nested) a #homepage element.
If you only want ps that are directly inside #homepage, use a child selector, like this: $('#homepage > p').
For more information, read the documentation.
$("div#homepage p") or $("div#homepage>p") if you need "direct" children of #homepage.