Deal of the Day

Home » Main » Manning Forums » 2007 » jQuery in Action

Thread: finding elements inside other elements

Reply to this Thread Reply to this Thread Search Forum Search Forum Back to Thread List Back to Thread List

Permlink Replies: 5 - Pages: 1 - Last Post: Jan 31, 2010 6:23 PM by: bear.bibeault
maya90

Posts: 36
From: nyc
Registered: 5/6/09
finding elements inside other elements
Posted: Jan 30, 2010 10:37 PM
  Click to reply to this thread Reply

can you in jQuery refer to sub-elements? for example can you do with jQuery what you can do like this with CSS?

li.subnav a ?????

how do I in jQuery refer to all 'a' elements that occur ONLY inside an 'li' element of class 'subnav'?????

thank you...

bear.bibeault


Posts: 487
From: Austin TX
Registered: 8/15/05
Re: finding elements inside other elements
Posted: Jan 30, 2010 11:08 PM   in response to: maya90 in response to: maya90
  Click to reply to this thread Reply

Absolutely!

maya90

Posts: 36
From: nyc
Registered: 5/6/09
Re: finding elements inside other elements
Posted: Jan 31, 2010 11:07 AM   in response to: bear.bibeault in response to: bear.bibeault
  Click to reply to this thread Reply

thank you very much.. could you please tell me HOW??

(that was the point of my question.....;_)

bear.bibeault


Posts: 487
From: Austin TX
Registered: 8/15/05
Re: finding elements inside other elements
Posted: Jan 31, 2010 12:50 PM   in response to: maya90 in response to: maya90
  Click to reply to this thread Reply

You've already got it right:

$('li.subnav a')

maya90

Posts: 36
From: nyc
Registered: 5/6/09
Re: finding elements inside other elements
Posted: Jan 31, 2010 5:29 PM   in response to: bear.bibeault in response to: bear.bibeault
  Click to reply to this thread Reply

oh my gosh, had no idea (don't remember seeing this in the book..)

thank you!!! :)

bear.bibeault


Posts: 487
From: Austin TX
Registered: 8/15/05
Re: finding elements inside other elements
Posted: Jan 31, 2010 6:23 PM   in response to: maya90 in response to: maya90
  Click to reply to this thread Reply

Chapter 2 clearly calls out all the CSS rules.

For the most part, if it works in CSS, it works as a jQuery selector.

Legend
Gold: 300 + pts
Silver: 100 - 299 pts
Bronze: 25 - 99 pts
Manning Author
Manning Staff