to apply it to a specific id, you need to just mention the id in the
selector.

eg.) $('#testid')

in DOM it is important that the ID is unique, if you do have multiple nodes
with same ids, which is a violation of HTML, the ID selector will always
return the first node with that ID.

For a class you can supply the class as well directly.

eg.) $('.className')

Although for classes you, if you may, specify some hierarchy of elements or
classes by separating them using spaces as you mentioned within your example

eg) $('.test ul li a')

the above selector will select anchor nodes (a), which are children (not
necessarily direct children) of li elements which inturn are children of ul
eliments which are children of an element with className as test.

Thanks & Regards,
Dhruva Sagar.




On Fri, Jan 15, 2010 at 8:23 AM, J <jesseparent...@gmail.com> wrote:

> Hi,
>
> Im new to jquery.
>
> I have a .hover that is applied to all ul li a
> $("ul li a").hover
>
> Question: How can I apply the .hover to a specific class or id?
>
> I tried something like this but it didn't work for me:
> $("#test ul li a").hover
> $("test ul li a").hover
>
> Thanks
>

Reply via email to