here we go again... :-)

I replied to a similar question regarding specifying an ID inside of a class a few days ago.

same thing applies to ID inside an ID...

This paragraph from the reference section of the upcoming Learning jQuery book might help explain why someone would want or need to preselect a class first. It discusses specifying a tag name rather than a class, but the same principle applies:

It might not be immediately clear why someone might want to specify a tag name associated with a particular id, since that id needs to be unique anyway. However, some situations in which parts of the DOM are user-generated may require a more specific expression to avoid false positives. Furthermore, when the same script is run on more than one page, it might be necessary to identify the id's element, since the pages could be associating the same id with different elements. For example, Page A might have <h1 id='title'> while Page B has <h2 id='title'>.

Hope that makes sense.

--Karl
_________________
Karl Swedberg
www.englishrules.com
www.learningjquery.com



On Jun 4, 2007, at 1:28 PM, Sean Catchpole wrote:


More importantly, why are you using two ID's?
Remember, ID's are supposed to be unique, so just $('#bar') should work. If your ID's aren't unique, I highly suggest you change them to classes.

~Sean

Reply via email to